Plooting pcolor plot for multiple matrix

3 ビュー (過去 30 日間)
Fiddin Ichwanul Alhaz
Fiddin Ichwanul Alhaz 2016 年 8 月 11 日
コメント済み: MJ Thangaraj 2020 年 3 月 13 日
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
Swathik Kurella Janardhan 2016 年 8 月 15 日
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
Fiddin Ichwanul Alhaz 2016 年 10 月 27 日
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 Center および File ExchangeGeographic Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by