Creating a function to plot multiple column of a variable in workspace
10 次查看(过去 30 天)
显示 更早的评论
I have a array which is 729 by 9
.
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/145856/image.jpeg)
.
.
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?
0 个评论
采纳的回答
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?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!