Function : undefined function or variable

조회 수: 5 (최근 30일)
ABDALLAH BOINA Safinati-Amir
ABDALLAH BOINA Safinati-Amir 2020년 11월 8일
Hello,
i'm wrote a function fun in a "Vc.m" file and i have to use it in the lsqcurvefit function that i wrote in another file "Identification.m" to find the constants b,m and R as shown below. In my first file i have the message "The function f might be unused" could someone help me please ?
Vc.m
function [Vc] = fun(j,b,m,R)
Vc(j) = E0-b.*log(j)-R.*j-m.*exp(n.*j);
end
Identification.m
j = [5 30 55 80 105 130 155 180 205 230 255 280 305 330 355 380 405 430 ...
455 480 505 530 555 580 605 630 655 680 705 730 755 780 805 830 855 880];
V80 = [1.0020 0.9448 0.9229 0.9037 0.8942 0.8810 0.8723 0.8630 0.8548 0.8427 ...
0.8379 0.8272 0.8152 0.8108 0.8025 0.7921 0.7882 0.7806 0.7770 0.7691 ...
0.7635 0.7552 0.7473 0.7406 0.7347 0.7300 0.7222 0.7099 0.7065 0.6985 ...
0.6932 0.6835 0.6793 0.6679 0.6561 0.6543];
x0 = [0;0];
E0 = 1.5;
n = 8.0E-3;
v80 = lsqcurvefit(@fun,x0,j,V80);

채택된 답변

dpb
dpb 2020년 11월 8일
"wrote a function fun in a "Vc.m" file"
but the function
function [Vc] = fun(j,b,m,R)
Vc(j) = E0-b.*log(j)-R.*j-m.*exp(n.*j);
end
is fun, not VC and so it should be saved in and referred to as fun.m not Vc.m

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Nonlinear Optimization에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by