How to plot the range at a certain value across multiple arrays?

I am trying to write the code that will plot the change along the 16th row across all k values. M is a 26x7 matrix iterated 101 times
M = T(1:n_i , 1:n_j , 1:k);
I tried
plot(T(16,1:n_i,1:k))
-----edit
line 83 defines the matrix
edit2: let's say
M1=[a b c d ; e f g h ; i j k l]
M2=[a+n b+n c+n d+n ; etc] where each element increases over time.
And this iterates k times. Say I want to plot the change of the 2nd row [e f g h] over time. How would I do this?

9 comentarios

Showing us exactly what you have so we can try to reproduce, for starters.
I really can't begin to fathom what you're trying to describe, sorry...
Please see the link attached in the edit
More code and trouble than I'm willing to go to...show us a small example of a matrix and what you're trying to extract where we can easily play with it. Help us help you...
Hopefully what I edited again was clear enough, thank you for your patience.
I don't know precisely what
M2=[a+n b+n c+n d+n ; etc]
means???
If something iterates, where does the new data get stored and how?
If you mean you're updating the values in M2, the only way to plot the change would be to compute the change and plot it before it is confounded into the array; after that point it's lost.
All of the values in M increase by a small amount. Each matrix (M1, M2.... M101) is stored in a 'for' statement. (Not sure if my wording is correct.)
But I can pull up all 101 matrices by inputting M. I just need the change of one specific row of M as it increases
"Each matrix (M1, M2.... M101)..."
There's your problem. See the Wiki FAQ on why not to create serially-named variables and how to avoid them... <Create variables A1 A2 ....>
Thank you, I will try that approach
@Evan Perovich: acessing variable names dynamically is slow, complex, buggy, and hard to debug. It obfuscates the code intent and makes code insecure. Rather than trying to access variable names in a loop you should simply put all of your data into one array, and accessing it using indexing. Indexing is simple, neat, extremely efficient, and easy to debug (unlike what you are trying to do). Read this to know more:

Respuestas (1)

Hi, I don't know if dpb's comment solved your problem but if you are still using,

M = T(1:n_i , 1:n_j , 1:k);

You can use 'permute' command. In case of 2D data, MATLAB uses columns as data. So, we switch iterations to represent rows and required data as columns.

L = permute(M,[3,2,1]);
plot(L(:,:,16));         % This would plot the 16th row of M as function of iterations

P.S. - This is my first answer. So, if I missed anything, please tell me.

La pregunta está cerrada.

Etiquetas

Preguntada:

el 17 de Abr. de 2018

Cerrada:

el 20 de Ag. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by