How to add multiple indices to graph title, legend, and output image?
4 ビュー (過去 30 日間)
古いコメントを表示
Motivation: I want to automatize the loading, processing and output of multiple data. Indices such as i, j, k, etc... are used to distinguish them. The output should have the same input indices.
Example: For the case of one data (graph and output image), I have the following command lines:
i=5;
f=figure(i);
x = 0:pi/100:2*pi;
y = sin(x-i);
h=plot(x,y);
legend(h,sprintf('sin(x-%d)',i),1);
title(['GRAPH\_',num2str(i)]);
print(f,'-dtiff', ['IMAGE_',num2str(i)]);
PROBLEM: I have multiple indices and I want that all of them be part of graph title and image name, so I changes the lines above intuitively to:
i=5;
j=3;
k=7;
f=figure(i,j,k);
x = 0:pi/100:2*pi;
y = j*sin(k*x-i);
h=plot(x,y);
legend(h,sprintf('%d*sin(%d*x-%d)',j,k,i),1);
title(['GRAPH_%d_INDJ_%d_INDK_%d',num2str(i,j,k)]);
print(f,'-dtiff', ['GRAPH_%d_INDJ_%d_INDK_%d',num2str(i,j,k)])
I expected to obtain:
graph title: GRAPH_5_INDJ_3_INDK_7; and
image name: GRAPH_5_INDJ_3_INDK_7,
where indices(IND)5 3 and 7 are part of titles and names.
But unfortunately I obtain the following error:
??? Error using ==> figure
Too many input arguments.
f=figure(i,j,k);
So I wonder if someone could help me to correct these line so that I obtain what I expect.
Thank you in advance for your help
Emerson
0 件のコメント
採用された回答
Amit Davidi
2012 年 2 月 2 日
The last line should be:
print(f,'-dtiff', sprintf('GRAPH_%d_INDJ_%d_INDK_%d',i,j,k))
その他の回答 (2 件)
Walter Roberson
2012 年 2 月 2 日
figure gets passed the single figure number of the figure to create. What would you like to have happen with the triple index, taking in to account that figure numbers can only be integers and not vectors?
Amit Davidi
2012 年 2 月 2 日
If I understand you correctly, I don't think you need to number the figure. You can just use:
f = figure;
By the way, once you'll solve this error, you're expected to get another one... You use twice this line:
['GRAPH_%d_INDJ_%d_INDK_%d',num2str(i,j,k)]
You should replace with:
sprintf('GRAPH_%d_INDJ_%d_INDK_%d',i,j,k)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!