Hi Guys,
I have some variables (D1,D2,D3,...) and I want to draw the graph for them .Since, number of variables are so much, I want to define the plot funtion in such a way that the variable changes automatically. My initial suggestion was to use eval function as follows: plot(eval(['D' num2str(j)])(:,11),D11(:,1),'linewidth',1) But id doesnt work. Could you please let me know any suggestion to solve it.
Cheers,

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 22일

0 개 추천

for k=1:3
eval(sprintf('plot(D%d)',k))
hold on
end

댓글 수: 3

jamaledin
jamaledin 2014년 4월 22일
Thank you for your reply.It works. Could ou please tell me, if I want to just draw specific numbers of rows and columns, how can I indicate it in this function? For example: plot(D11(:,1),D11(:,2))
Jamaledin, using several variables is not a good idea. you can create one variable
v=[D1;D2;...]
or a cell array
v={D1 D2 ...]
jamaledin
jamaledin 2014년 4월 22일
Many thanks for your support Azzi. Your recommendation is completely right. I redefined the arrays as follows and It works:
for i=1:11 D{i} = a(6+L(1,i):5+L(1,(i+1)),:); end
plot(D{i}(:,11),D{i}(:,1),'linewidth',1)
Many thanks for your replies. Best Regards, Jamaledin

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

질문:

2014년 4월 22일

댓글:

2014년 4월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by