The fzero function is a root-finder, so the function it is given to solve must equate to 0 for any delection of independent variables. I implemented that approach in the revised coding of ‘fun’ here:
k = 0.9;
n = 2;
c0 = 2;
V = 100:10:200;
F = 10:1:100;
V = linspace(100, 200, 25);
F = linspace(10, 100, 50);
VF = @(x) (x)./((k*c0.^n)*((1-x).^n));
fun = @(x,V,F) V./F - (x)./((k*c0.^n)*((1-x).^n));
for k1 = 1:numel(V)
for k2 = 1:numel(F)
x(k2,k1) = fzero(@(x)fun(x,V(k1),F(k2)),0.5);
end
end
figure
surfc(V, F, x)
grid on
xlabel('V')
ylabel('F')
zlabel('Conversion')
view(130,10)
produces:
.
Best Answer