Plot multiple tables from workspace using for loop

조회 수: 5 (최근 30일)
Claretconnor
Claretconnor 2021년 12월 4일
댓글: Claretconnor 2021년 12월 7일
I have multiple 1024x2 tables in my work space named x1-x30 , each table consists of a wavelength column and an emission column, I want to be able to produce a for loop that plots each table onto the same graph. Similar to this in c:
for(int i=1; i<=30;i++)
{plot(x(n).Wavelength, x(n).emission)}

채택된 답변

Dave B
Dave B 2021년 12월 4일
If you want to reference the tables as you describe, you'd need them in an array (in C, or in MATLAB):
t1=table((1:10)',rand(10,1));
t2=table((2:11)',rand(10,1)+.5);
t3=table((3:12)',rand(10,1)+1.5);
clf;
hold on
x = {t1, t2, t3}; % cell array of tables
for i=1:numel(x)
plot(x{i}.Var1, x{i}.Var2)
end
  댓글 수: 1
Claretconnor
Claretconnor 2021년 12월 7일
Sorry im new to matlab so took me a while to understand but this works a treat! thank you so much!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by