MATLAB Answers

Use fzero() to calculate x required to achieve V/F for every combination of V and F.

100 views (last 30 days)

Accepted Answer

Star Strider
Star Strider on 28 Oct 2020 at 3:10
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; %initial concentration (mol/m^3)
V = 100:10:200;
F = 10:1:100;
V = linspace(100, 200, 25);
F = linspace(10, 100, 50);
%initial guess = 0.5 (can be anything)
VF = @(x) (x)./((k*c0.^n)*((1-x).^n)); % Not Directly Used
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:
.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by