How to generate the n number of figure for n numbers of subplots
Show older comments
This is my pseudo-code for my model
function my_plot(n)
A = zeros(n,n);
x(1:1:size(A,1),1) = 293.50;
load('Measuring_Data.mat');
axes1 = axes('Parent',figure);
set(gca,'XTick',0:1:size(A,1));
set(gca,'XTickLabel',0:1:size(A,1));
%set(gca,'YTick', 100:10:1000);
% Create xlabel
xlabel('Node Points','FontSize',14);
xlim([0 size(A,1)]);
% Create ylabel
ylabel('Temperatur in °C','FontSize',14);
% Create title
title('Stationary Node Temperatures',...
'FontSize',16);
hold on
y = 1:1:size(A,1);
bar(y, x(:),0.4);
hold off
% I am talking about this section :
% I know title should be entered manually, kindly leave that part.
figure('Color',[1 1 1]);
subplot 231
hold on
bar(1,x(1,:),'FaceColor',[0.94 0.94 0.94],'LineWidth',1);
hold on
bar(2,Measuring_Data(1,1),'FaceColor',[0, 0 , 0],'LineWidth',1);
title('K 1');
ylim([0,100]);
subplot 232
hold on
bar(1,x(2,:),'FaceColor',[0.94 0.94 0.94],'LineWidth',1);
hold on
bar(2,Measuring_Data(2,1),'FaceColor',[0.25 0.25 0.25],'LineWidth',1);
title('K 2');
ylim([0,100]);
subplot 233
hold on
bar(1,x(3,:),'FaceColor',[0.94 0.94 0.94],'LineWidth',1);
hold on
bar(2,Measuring_Data(3,1),'FaceColor',[0.25 0.25 0.25],'LineWidth',1);
title('K 3');
ylim([0,100])
subplot 234
hold on
bar(1,x(4,:),'FaceColor',[0.94 0.94 0.94],'LineWidth',1);
hold on
bar(2,Measuring_Data(4,1),'FaceColor',[0.25 0.25 0.25],'LineWidth',1);
title('K 4');
ylim([0,100]);
legend('Simulation','Messung', 'Location', 'Northeast');
subplot 235
hold on
bar(1,x(5,:),'FaceColor',[0.94 0.94 0.94],'LineWidth',1);
hold on
bar(2,Measuring_Data(5,1),'FaceColor',[0.25 0.25 0.25],'LineWidth',1);
title('K 5');
ylim([0,100]);
% subplot 236
% hold on
% bar(1,x(6,:),'FaceColor',[0.94 0.94 0.94],'LineWidth',1);
% hold on
% bar(2,Measuring_Data(6,1),'FaceColor',[0.25 0.25 0.25],'LineWidth',1);
% title('K 6');
% ylim([0,100])
end
Now If I enter my_plot(5) in the command window it will work along with give the subplot figure also.
Now I want to change n to 20 from 5. At that time only first figure will come, second figure with measuring data will not come since n will be more than 5.
Now my question is how to build the code, so subplot will be generated for n number amd also n figure will be generated for n number.
To run the code, write any numbers in measuring data for your understanding purpose. but It should be n*1 matrix. like 23;45;60;54;21;79;.....
I don't know is it possible or not?
If possible kindly give me a hint or code or suggestions.
Thanks in advance.
Accepted Answer
More Answers (0)
Categories
Find more on Subplots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!