Creating a function to plot multiple column of a variable in workspace

3 ビュー (過去 30 日間)
hithere
hithere 2014 年 10 月 26 日
コメント済み: hithere 2014 年 10 月 30 日
I have a array which is 729 by 9
.
.
.
.
Currently I am plotting the different columns in the same plot using the follow command:
.
plot(wavelengtha(:,1), Raman);
hold on;
plot(wavelengtha(:,2), Raman);
hold on;
plot(wavelengtha(:,3), Raman);
hold on;
plot(wavelengtha(:,4), Raman);
hold on;
.
.
.
.
plot(wavelengtha(:,9), Raman);
.
. This is still manageable as its only 9 columns. however in later stage, I will have arrays stretching up to 100+ columns. I was thinking of putting the above code in function. Where I will then key in the name of the variable to plot all the columns as y-axis.
. Can Someone help me with this?

採用された回答

Roger Stafford
Roger Stafford 2014 年 10 月 26 日
Just use a for-loop for this purpose:
for k = 1:n
plot(wavelengtha(:,k), Raman);
hold on
end
What could be simpler?
  1 件のコメント
hithere
hithere 2014 年 10 月 30 日
But how do i write them in function. Because I got a list of wavelength.
wavelengthx_50
wavelengthx_49
.
.
.
wavelengthx_1
So i was thinking of writing a fucntion where i will input the eg. wavelengthx_48
and it will plot out the Figure(wavelengthx_48).

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by