Plooting pcolor plot for multiple matrix

10 visualizzazioni (ultimi 30 giorni)
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 Commento
KSSV
KSSV il 11 Ago 2016
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.

Accedi per commentare.

Risposta accettata

Swathik Kurella Janardhan
Swathik Kurella Janardhan il 15 Ago 2016
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

Più risposte (1)

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

Accedi per commentare.

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by