Plooting pcolor plot for multiple matrix

3 次查看(过去 30 天)
Hi Guys,
I have 3 different huge matrix (as an example, in fact I have hundreds matrix), lets call it a1,a2,a3. I would like to plot them as pcolor. Each of them are positioned in a subplot. as you can see, it is pretty hectic to repeat the codes several times since I have hundreds of matrix. Is there any better way to do it? You can see my code below.
Thank you very much.
close all;
clear all;
clc
%call from ReadData script
ReadData;
disp ('2D view plotted')
%Plotting
rot_a1 = rot90(a1);
subplot (4,1,1)
figure (1);
pcolor(rot_a1); %plot raw data dari Tekscan to analyzed fooprint shape
set(gca,'fontsize',8);
caxis ([0 2000]); %Set up colorbar
x_range = 0:20:80;
set(gca,'XTick', x_range);
set(gca,'XTickLabel',num2cell(floor(x_range*5.08)));
y_range = 0:20:90;
set(gca,'YTick', y_range);
set(gca,'YTickLabel',num2cell(floor(y_range*5.08)));
colormap(jet (256));
ylabel('Longitudinal (mm)','fontsize',8);
xlabel('Lateral (mm)','fontsize',8);
shading('interp'); % control the color shading of the plot surface
% colorbar('horiz'); % plot a color bar
title('500 kPa, 10 kN','FontSize',9);
rot_a2 = rot90(a2);
subplot (4,1,2)
figure (1);
pcolor(rot_a2); %plot raw data dari Tekscan to analyzed fooprint shape
set(gca,'fontsize',8);
caxis ([0 2000]); %Set up colorbar
x_range = 0:20:80;
set(gca,'XTick', x_range);
set(gca,'XTickLabel',num2cell(floor(x_range*5.08)));
y_range = 0:20:90;
set(gca,'YTick', y_range);
set(gca,'YTickLabel',num2cell(floor(y_range*5.08)));
colormap(jet (256));
ylabel('Longitudinal (mm)','fontsize',8);
xlabel('Lateral (mm)','fontsize',8);
shading('interp'); % control the color shading of the plot surface
% colorbar('horiz'); % plot a color bar
title('500 kPa, 20 kN','FontSize',9);
rot_a3 = rot90(a3);
subplot (4,1,3)
figure (1);
pcolor(rot_a3); %plot raw data dari Tekscan to analyzed fooprint shape
set(gca,'fontsize',8);
caxis ([0 2000]); %Set up colorbar
x_range = 0:20:80;
set(gca,'XTick', x_range);
set(gca,'XTickLabel',num2cell(floor(x_range*5.08)));
y_range = 0:20:90;
set(gca,'YTick', y_range);
set(gca,'YTickLabel',num2cell(floor(y_range*5.08)));
colormap(jet (256));
ylabel('Longitudinal (mm)','fontsize',8);
xlabel('Lateral (mm)','fontsize',8);
shading('interp'); % control the color shading of the plot surface
% colorbar('horiz'); % plot a color bar
title('500 kPa, 30 kN','FontSize',9);
rot_a4 = rot90(a4);
subplot (4,1,4)
figure (1);
pcolor(rot_a4); %plot raw data dari Tekscan to analyzed fooprint shape
set(gca,'fontsize',8);
caxis ([0 2000]); %Set up colorbar
x_range = 0:20:80;
set(gca,'XTick', x_range);
set(gca,'XTickLabel',num2cell(floor(x_range*5.08)));
y_range = 0:20:90;
set(gca,'YTick', y_range);
set(gca,'YTickLabel',num2cell(floor(y_range*5.08)));
colormap(jet (256));
ylabel('Longitudinal (mm)','fontsize',8);
xlabel('Lateral (mm)','fontsize',8);
shading('interp'); % control the color shading of the plot surface
% colorbar('horiz'); % plot a color bar
title('500 kPa, 40 kN','FontSize',9);
  1 个评论
KSSV
KSSV 2016-8-11
What dimensions the matrices are? what is rot90? you need not to make that a huge attempt to plot it..it can be done with single plot command and a loop.

请先登录,再进行评论。

采纳的回答

Swathik Kurella Janardhan
As Dr. Siva Srinivas Kolukula mentioned, you can put the code to plot inside a loop and the matrices inside a cell vector and index the cell vector to plot each matrix inside the loop.
I modified your code for two matrices and initialized the matrices with sample values as below:
close all;
clear all;
clc
%call from ReadData script
% ReadData;
% Initialize two matrices with sample values
a1 = ones(10,10);
a2 = ones(20,20);
a = cell(2);
a{1} = a1; a{2} = a2;
disp ('2D view plotted')
for idx = 1:length(a)
%Plotting
% index cell vector for required matrix
rot_a1 = rot90(a{idx});
% use index to position the sub plot
subplot (4,1,idx)
figure (1);
pcolor(rot_a1); %plot raw data dari Tekscan to analyzed fooprint shape
set(gca,'fontsize',8);
caxis ([0 2000]); %Set up colorbar
x_range = 0:20:80;
set(gca,'XTick', x_range);
set(gca,'XTickLabel',num2cell(floor(x_range*5.08)));
y_range = 0:20:90;
set(gca,'YTick', y_range);
set(gca,'YTickLabel',num2cell(floor(y_range*5.08)));
colormap(jet (256));
ylabel('Longitudinal (mm)','fontsize',8);
xlabel('Lateral (mm)','fontsize',8);
shading('interp'); % control the color shading of the plot surface
% colorbar('horiz'); % plot a color bar
title('500 kPa, 10 kN','FontSize',9);
end

更多回答(1 个)

Fiddin Ichwanul Alhaz
Thank for the help Dr. Siva Srinivas Kolukula and Swathik Kurella Janardhan. Really appreciate it.
  1 个评论
MJ Thangaraj
MJ Thangaraj 2020-3-13
Hey Alhaz,
I'm currently working on Tekscan for tire-pavement intercation. Anyway I could contact you for a couple of question.
Thank you

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Geographic Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by