How to save each loop ieration for creating a surf
2 views (last 30 days)
Show older comments
Hello everyone,
I'm new to matlab and I`m working on the following code: h0 = ecv(0.7:0.05:1); h1 = ecv(0.7:0.05:1); FN = zeros(size1(h0),size1(h1),3); FP = zeros(size1(h0),size1(h1),3); ... for k=1:3 ... surf(h0, h1, FP-FN);
continue;
end
The code is long and contains a lot of other functions, that`s why I have replaced irrelevant pieces with ... The question is the following: The loop for k=1:3 generates 3 different values of FP. I need the results of all the loops in 3 different surface plots. Matlab shows an error by using the function surf everytime, because data dimensions must agree. I don't know how to fix the problem, tried many options, but I don't get it...
thank you much for your help!!
0 Comments
Answers (1)
Voss
on 21 Feb 2022
Edited: Voss
on 21 Feb 2022
I'm not sure what functions or variables ecv and size1 are, but maybe the following bit of code can be a useful reference (note FN and FP are 2D, and notice the order of the first two inputs to surf()):
h0 = 0.7:0.05:1;
h1 = 0.7:0.05:1.1;
FN = zeros(numel(h0),numel(h1));
FP = zeros(numel(h0),numel(h1));
for k=1:3
surf(h1, h0, FP-FN);
hold on
FP = FP+0.2; % make the surfaces different
end
Or maybe something like this (with 3D FN and FP) is what you mean to do:
figure();
h0 = 0.7:0.05:1;
h1 = 0.7:0.05:1.1;
FN = zeros(numel(h0),numel(h1),3);
FP = zeros(numel(h0),numel(h1),3);
for k=1:3
surf(h1, h0, FP(:,:,k)-FN(:,:,k) + 10*k); % + 10*k to make the surfaces different
hold on
end
1 Comment
Miriam Kahlert
on 25 Jun 2023
Hello,
my problem is, i want to draw a new plot for each loop. But i can't get it to do that.
Any advice?
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!