Saving a 3D matrix in through FOR LOOP and plot this matrix with error bar with error bar
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
dpb
2022-9-20
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!