a queston to plot

1 回表示 (過去 30 日間)
Rica
Rica 2014 年 3 月 18 日
編集済み: Patrik Ek 2014 年 3 月 18 日
hi all
i have variables : a1, a2, ...........................a100
i want to plot them in one plot: i wrote this program to load them
for i=1:100
load (['a' num2str(i) '.mat'])
end
what schould i write in the same plot to get the plot of all elements in the same plot?
thankl you

回答 (2 件)

Chandrasekhar
Chandrasekhar 2014 年 3 月 18 日
for i=1:100
load (['a' num2str(i) '.mat'])
hold on
end

Francesco
Francesco 2014 年 3 月 18 日
figure(1)
for i=1:100
load (['a' num2str(i) '.mat'])
plot(a)
hold on
end
hold off
However the problem is the color: you can try to build a 100x3 matrix containing the values of the colors you want but it is too long plus for a 100 plots you might get colors that are too similar
  2 件のコメント
Rica
Rica 2014 年 3 月 18 日
thanks for the answer. I dont have a as variable, but a1,a2,....a100
regards
Patrik Ek
Patrik Ek 2014 年 3 月 18 日
編集済み: Patrik Ek 2014 年 3 月 18 日
You can try
plot(eval(['a' num2str(i) '.mat']));
It is said that eval may give the wrong result sometimes, but it have not happened for me yet. However, if you want to do something else that is more safe you can do
q = load (['a' num2str(i) '.mat'])
qnames = fieldnames(q);
plot(q.(qnames{1}));
or you can search for a replacement for eval.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by