Ploting stack of matrices

2 visualizzazioni (ultimi 30 giorni)
sharay
sharay il 18 Ott 2019
Commentato: Walter Roberson il 21 Ott 2019
Hi,
I have stack of 100 A= 4*4 matrices ,and a vector of B= 1*100 elements. I want to plot (B,A) . What are possible solutions for this ? Do I have to make a function that will respond to one matrix ata time for certain element ?
Also in matlab if you have 100*4*4 matrix what does it mean?
  4 Commenti
Walter Roberson
Walter Roberson il 18 Ott 2019
How many lines do you expect to be drawn as a result?
sharay
sharay il 21 Ott 2019
In total 16 lines.

Accedi per commentare.

Risposte (3)

KALYAN ACHARJYA
KALYAN ACHARJYA il 18 Ott 2019
Modificato: KALYAN ACHARJYA il 18 Ott 2019
A=randi(100,[100 4 4]);
%........... ^[rows column number of stack planes]
B=randi(100,[100 4]);
[r c d]=size(A); % d represents here number of stacks planes
for i=1:d
plot(A(:,:,i),B);
hold on;
end
Read about multidimentinal array here
But if I have to generate 100 4*4 matrices what should be the procedure?
Are you looking for 100 stacks for 4x4 matrics, then
A=randi(100,[4 4 100]);
%.......^ represents maximum allowed values in the randomly generated matrics
Non Integer, then
A=rand(4,4,100);
Hope it helps!
  6 Commenti
sharay
sharay il 18 Ott 2019
yes, this is the problem. for one element i have 16 elements. so for 100 elements on x-axis , i have to plot 1600 elements .
KALYAN ACHARJYA
KALYAN ACHARJYA il 18 Ott 2019
Modificato: KALYAN ACHARJYA il 18 Ott 2019
You can talk with me through my number (please check profile)

Accedi per commentare.


sharay
sharay il 18 Ott 2019
Thnak you . I solved this issue. Can someone help me with ploting like now i have 100*1 matrix and I want to plot it with 4*4 matrices of 100 layers. Should i assign function ?

Walter Roberson
Walter Roberson il 18 Ott 2019
If you have x being a 100 x 1 matrix, and y being as 100 x 4 x 4 matrix, then
plot(x, reshape(y, size(y,1), []))
This would create 16 lines, in the order y(:,1,1), y(:,2,1), y(:,3,1), y(:,4,1), y(:,1,2), y(:,2,2), y(:,3,2) and so on.
  2 Commenti
sharay
sharay il 21 Ott 2019
Input is 1x100 and output is 4x4x100.
Walter Roberson
Walter Roberson il 21 Ott 2019
Yp =
reshape( permute(y, [3 1 2]), [], 16);
plot(x, Yp) ;

Accedi per commentare.

Categorie

Scopri di più su Resizing and Reshaping Matrices 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