I have a matrix in which the values are mainly in the main diagonal. What i want to do is create a bigger matrix in which each row of the matrix is a line so it would show the values of each row across several lines. So for example if i have an identity 3x3 matrix, it would be three lines with spikes on the main diagonal.

13 commentaires

jonas
jonas le 23 Oct 2018
Modifié(e) : jonas le 23 Oct 2018
And what is the problem with
plot(YourMatrix)
?
Feliciano Döring
Feliciano Döring le 23 Oct 2018
It doesn't display it as i want it to. Plot(matrix) will only show me a single line with the variations of the values i have.
KSSV
KSSV le 24 Oct 2018
How about waterfall?
Feliciano Döring
Feliciano Döring le 24 Oct 2018
I tried the waterfall plot and it gets close to how i want to display it, but i was looking for something more like 2D, not 3D.
jonas
jonas le 24 Oct 2018
Modifié(e) : jonas le 24 Oct 2018
imshow? pcolor? Imagesc? Scatter?
I still do not understand what you want to do.
Feliciano Döring
Feliciano Döring le 24 Oct 2018
Honestly i think imshow is almost the same as imagesc and i tried both hahaha. Tried pcolor and it wasn't that much different from the previous and scatter didn't quite work for the matrix
jonas
jonas le 24 Oct 2018
Modifié(e) : jonas le 24 Oct 2018
pcolor and/or imagesc omits one row/column on the edge, so if you have a 3x3 matrix you will get 2x2 squares. This is not a problem with imshow. The problem with imshow is that you need regular spacing between pixels. Anyway, is this type of grid what you were going for?
Feliciano Döring
Feliciano Döring le 24 Oct 2018
Oh, i didn't know thanks! But it's not what i'm looking for. I used the identity matrix as an example but what my actual matrix has main values on the main diagonal with decreasing values on each side of the rows, so each row would look more like a gaussian distribution.
jonas
jonas le 24 Oct 2018
Modifié(e) : jonas le 24 Oct 2018
Maybe it's clear to you how you want to visualize your data, maybe not, maybe you only have a vague picture in your head. Regardless, what you just said does not describe how you want to visualize your data. The nature of your data does not describe how you want to visualize your data. In fact, the nature of your data does not matter at all. All that matters is how you want to visualize the data in question. Can you... draw a sketch by hand?
Feliciano Döring
Feliciano Döring le 24 Oct 2018
Yes, of course, here it is. Less of a squetch more of a print of a book
jonas
jonas le 24 Oct 2018
Modifié(e) : jonas le 24 Oct 2018
Back to my original enquiry, what is wrong with plot? Does the rows of your matrix describe the coordinates of these distribution plots? Can you upload your data?
In the case of the identity matrix, are you looking for something like this? (5x5)
Feliciano Döring
Feliciano Döring le 24 Oct 2018
The plot doesn't quite fit. But here take a look
Feliciano Döring
Feliciano Döring le 24 Oct 2018
Yes, something like this

Connectez-vous pour commenter.

 Réponse acceptée

jonas
jonas le 24 Oct 2018
Modifié(e) : jonas le 24 Oct 2018
Here's a custom plot type I made. It may look upside down, but the value on the y-axis denotes the row number. The "peak value" of the lines are scaled and only show relative height.
A = eye(5);
scale = 2;
figure;hold on
for j = 1:size(A,1);
y = A(j,:)./scale+j;
fill([1 1:size(A,1) size(A,1)],[min(y) y min(y)],'r');
end
If you prefer the reverse order, as they appear in the matrix, then just change the 5th line to
y = A(j,:)./scale+(size(A,1)-j);

5 commentaires

Feliciano Döring
Feliciano Döring le 24 Oct 2018
Thanks, this helps a lot! And double thanks for the patience :D
jonas
jonas le 24 Oct 2018
My pleasure! It's true that a picture says more than a thousand words ;)
Feliciano Döring
Feliciano Döring le 29 Oct 2018
One last question, I've been wondering if there is a way to change the matrix so that the diagonal goes from top left to down right.
I believe I adressed this in the original answer?
y = A(j,:)./scale+(size(A,1)-j);
Feliciano Döring
Feliciano Döring le 29 Oct 2018
Sorry, didn't pay attention '-.-

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Mathematics dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by