Matlab matrix syntax weird
Afficher commentaires plus anciens
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.
Réponses (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
.
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!