Allocating values in 1d matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Da'Moon
am 6 Dez. 2017
Bearbeitet: Da'Moon
am 6 Dez. 2017
B = p * ones(327,245,2, uint8); can i do it with a loop?
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 6 Dez. 2017
No need for for loops, especially ones that don't work. Simply use ones:
B = p * ones(327,245,2, 'uint8');
1 Kommentar
Image Analyst
am 6 Dez. 2017
Try this:
p=uint8(0);
for L = 3 : -1 : 1
for row = 327 : -1 : 1
for col = 245 : -1 : 1
B(row, col, L)=p;
end
end
end
It's a very inefficient way of doing it. I reverse the indexes to try to make it more efficient though. You should NOT want to do it this way.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!