How to add multiple indices to graph title, legend, and output image?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Emerson De Souza
el 2 de Feb. de 2012
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 comentarios
Respuesta aceptada
Amit Davidi
el 2 de Feb. de 2012
The last line should be:
print(f,'-dtiff', sprintf('GRAPH_%d_INDJ_%d_INDK_%d',i,j,k))
Más respuestas (2)
Walter Roberson
el 2 de Feb. de 2012
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
el 2 de Feb. de 2012
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)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!