How do I vectorize the following code?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I'm having trouble vectorizing the following code. The result should be a matrix with an upper triangle.
data = 1:1:10;
nn = length(data);
for x = 1:nn
for y = x:nn
X(x,y) = (data(y) - data(x)) / data(x);
end
end
All help gratefully received!
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!