Using values from an array as titles in generated figures
20 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
Michael Haderlein
2014-8-18
编辑:Michael Haderlein
2014-8-18
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Title 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!