Reputation: 1812
I have a matrix of, say:
size P = zeros(2,2,100);
Let's try to plot the first element of each of these matrices, like this:
plot(1:1:100, P(1,1,:))
This does not work. What is the proper way to do it?
Upvotes: 1
Views: 5508
Reputation: 121
Try plot(squeeze(P(1,1,:)).
The squeeze() function removes singleton dimensions (dimensions whose size are 1).
Upvotes: 5
Reputation: 1802
Solution: Create arrays manually. Not very elegant but works.
% tl = top left, br = bottom right, etc.
for i=1:1:100
tlplot(i) = P(1, 1, i);
trplot(i) = P(1, 2, i);
blplot(i) = P(2, 1, i);
brplot(i) = P(2, 2, i);
end
Then, for instance:
plot(1:1:100, tlplot)
Upvotes: 0