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

100 views (last 30 days)
Cate may on 28 Oct 2020 at 2:11
Commented: Rik on 31 Oct 2020 at 8:01
This question was flagged by Walter Roberson
k = 0.9;
n5

#### 1 Comment

Rik on 31 Oct 2020 at 8:01

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: .

Cate may on 28 Oct 2020 at 6:37
Thank you! Exactly what I expected
Star Strider on 28 Oct 2020 at 10:59
As always, my pleasure!