In Matlab I have data in the form:
k1=[1 2 3 ...]
f1=[34 23 12 ...]
k2=[ ... ]
f2=[ ... ]
k3=
f3=
...
To plot k1(f1) I use
plot (k1,f1)
How can I simply plot all k#(f#) on one figure without calling plot
every time?
Thank you
To write multiple variables use plot in order to get multiple variables on the same figure follow the pattern bellow..
k1=[1 2 3 ...]
f1=[34 23 12 ...]
k2=[ ... ]
f2=[ ... ]
k3=
f3=
figure
plot (k1,f1,k2,f2,k3,f3)
EDIT 1:
since your data is in vector form as shown in your question then concatenating them into groups of k
and f
will allow you to iterate through a loop and match the columns you want from each array with each other..
I put the source of this info as a link from youtube in the comments below then decided to add it here as wellfor convenience.
f1 = [34 23 12];
f2 = [5 6 7];
f3 = [18 22 34];
k1 = [1 2 3];
k2 = [3 5 6];
k3 = [8 3 2];
k = cat(1, k1, k2, k3);
f = cat(1, f1, f2, f3);
[~, col] = size(k);
hold on;
for kk = 1 : col
plot(k(:,kk), f(:,kk))
end