How to get fzero with 2 variables in array?
Show older comments
I want to get the x value for each y and alpha in array. But I got error like this
Error using fzero (line 274)
Function values at the interval endpoints must differ in sign.
Error in Term_Paper (line 14)
x(i)=fzero(@(y)dot(tp,fx(x)),[0.15 1]);
How to solve this?
%Parameters
xin=0.2; xout=0.1; Pr=0.3; qf=1;
y=0:0.1:1;
alpha=0:100:1000;
%For Cross-Flow Module (CF)
%y=(1+(x+Pr).*(alpha-1))-((1+(x+Pr).*(alpha-1)).^2-(4.*alpha.*(alpha-1).*x.*Pr)).^0.5/(2.*Pr.*(alpha-1))
%Calculating x
fx=@(x) ((1+((x+Pr).*(alpha-1))-((((1+((x+Pr).*(alpha-1))).^2)-(4.*alpha.*(alpha-1).*x.*Pr)).^0.5))/(2.*Pr.*(alpha-1)))-y;
x=zeros(size(fx(0.16)));
for i=1:length(x)
tp=zeros(size(x));
tp(i)=1;
x(i)=fzero(@(y)dot(tp,fx(x)),[0.15 1]);
end
Accepted Answer
More Answers (0)
Categories
Find more on Linear Algebra 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!