Saving a 3D matrix in through FOR LOOP and plot this matrix with error bar with error bar
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
How can I save the each value for row,col and slice for the following output R, which will be a 3D matrix. Lastly, plot this 3D matrix with error bar.
Your kind help will be appreciated.
Thank you.
For example,
row = [0.3 0.4 0.5];
col = [0.3 0.4 0.5];
sl = [1 2]; % slice in z axis
output >> R : 3x3x2 MATRIX
for a = 1:numel(sl);
for b = 1:numel(col);
for C = 1:numel(row);
R = myfunction (some parameters)
end
end
end
0 Kommentare
Antworten (1)
dpb
am 20 Sep. 2022
R=zeros(numel(row),numel(col),numel(sl)); % preallocate
...
R(C,b,a)=myfunction(...);
...
is the brute force way using explicit loops. "The MATLAB way" would be to vectorize the function itselt such that it accepted the inputs as vectors/arrays of the proper sizes and hid the looping constructs from the higher-level code.
As for how to plot a 3D array with error bars -- that's going to be a pretty difficult thing to do -- without any idea what the 3D array content represents, tough to have much idea on what a plot would be expected to look like, even...
0 Kommentare
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!