1
votes

I have a sequence of matrices I've created like this:

for i=1:n
Real{i}=Real_Trans^i;
Trans{i}=Trans_Est^i;
R{i}=abs(Real{i}-Trans{i});
end

where the user inputs n. Now, I want to plot lines for each element of every matrix R{i}. So, for example, let's take element (1,1). I need to get (1,1) from each matrix and make a line with them. Another line for all (1,2)'s. And keep going like that.

Thanks in advance !

1

1 Answers

0
votes

It would be easier if you had a 3D-array instead of a cell array of 2d-arrays.

Anyway, with your data R, you can use:

plot(reshape(cat(3, R{:}), [], numel(R)).', 'o-')

This exploits the fact that, according to plot's documentation,

plot(Y) plots the columns of Y versus their index.

Example: let's create 5 matrices of size 2x3:

for n = 1:5
    R{n} = randn(2,3);
end

Then the above code produces the following figure:

enter image description here