Function : undefined function or variable

3 views (last 30 days)
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);

Accepted Answer

dpb
dpb on 8 Nov 2020
"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

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!