Matlab matrix syntax weird
Mostrar comentarios más antiguos
Hello!
I am a newby to Matlab, and I have a small code fragment I cannot understand.
I need to know what the following lines do, but even trying to visualize them in Matlab, I was not able to find out the meaning:
p(:, :, 1)=u(:, [2:width, width])
p(:, :, 2)=u([2:height, height], :)
p(:, :, 1)=p(:, :, 1)
Can you please explain what those the above lines mean?
Thank you.
Respuestas (1)
It is likely easiest to assign a value to ‘height’ and ‘width’ and see the result —
height = 4; % Create VAlue
width = 5; % Create Value
u = randi(9,height,width) % Create Matrix
p(:, :, 1)=u(:, [2:width, width])
p(:, :, 2)=u([2:height, height], :)
p(:, :, 1)=p(:, :, 1) % This Is Obviously Redundant, Since It Assigns The First Page To The First PAge
.
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!