Using values from an array as titles in generated figures
24 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
So I have some code that runs through some data given to it multiple times, and creates figures based upon different apsects of the code.
What I want it to do now is to use an array (or another method) to name the figures base upon what run of the program it is on.
My current code is:
cd('....')
output_file='....'
var_name = ['VAR1, VAR2, VAR3, VAR4'];
for count_1 = 1:4;
current_var = var_name(count_1);
for count_2 = 1:10;
data = load(....)
current_data = count_1 + 4;
data_1 = data(:,1);
data_2 = data(:,2);
data_3 = data(:,current_data);
data_figure= figure('Visible','off');
axes1 = axes('Parent', data_figure, 'ZGrid', 'on', 'YGrid', 'on');
view(axes1,[0.5 90]);
xlim(axes1,[-0.01 0.25]);
hold(axes1, 'all');
surf(data_reshape_1,data_reshape_2,data_reshape_3, 'Edgecolor', 'none');
colorbar;
%ISSUE IN THE NEXT FEW LINES
title([num2str(count_2),'ns: ',[num2str(current_var),'.....']]);
xlabel('.....');
ylabel('.....');
ylabel(colorbar, [num2str(current_var)]);
set(gca, 'XGrid', 'off');
end
end
Everything works fine, apart from the fact that instead of using the values of what is in var_name in turn, it takes the letters from the first value in the array, i.e V, A, R, 1 and not the desired, VAR1, VAR2, VAR3, VAR4
Any help would be great.
0 comentarios
Respuestas (2)
Michael Haderlein
el 18 de Ag. de 2014
Editada: Michael Haderlein
el 18 de Ag. de 2014
var_name = ['VAR1, VAR2, VAR3, VAR4'];
I think you rather want it as a cell:
var_name = {'VAR1', 'VAR2', 'VAR3', 'VAR4'};
and then title with
title([num2str(count_2) 'ns: ' ', var_name{count_1} '.....'])
0 comentarios
Ver también
Categorías
Más información sobre Title en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!