How to get fzero with 2 variables in array?
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!