loops - Plot many functions in single figure in Matlab -
in matlab have data in form:
k1=[1 2 3 ...] f1=[34 23 12 ...] k2=[ ... ] f2=[ ... ] k3= f3= ...
to plot k1(f1) use
plot (k1,f1)
how can plot k#(f#) on 1 figure without calling plot
every time?
thank you
to write multiple variables use plot in order multiple variables on same figure follow 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 data in vector form shown in question concatenating them groups of k
, f
allow iterate through loop , match columns want each array each other..
i put source of info link youtube in comments below decided add here 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; kk = 1 : col plot(k(:,kk), f(:,kk)) end
Comments
Post a Comment