Unsupported use of the '=' operator. To compare values for equality, use '=='. To specify name-value arguments, check that name is a valid identifier with no surrounding quote

36 views (last 30 days)
I do not know why this is not working. I would like to use the solutions fo the curve fitting to perform some calculations but keep gettign this error. I would very much appreciate any help that can be provided
I have given my code below:
A = readtable('resit experimental data.xlsx')
t = A{:,1};
y = A{:,2};
start = [10.5, -0.00017, 9, -0.0058]; %from graphpeeling
f = @(a,b,c,d,t) [a*exp(-b*t) + c*exp(-d*t)] ; %% @ used to decalre a function
obj_fun = @(params) norm(f(params(1), params(2),params(3), params(4), t)-y); %% @ (params) used to decalre a function
sol = fminsearch(obj_fun, start);
a_sol = sol(1)
b_sol = sol(2)
c_sol = sol(3)
d_sol = sol(4)
hold on
grid on
title ('Data')
xlabel ('time(minutes)')
ylabel ('concentration (mg)')
plot(t, y, '+', 'MarkerSize', 10, 'LineWidth', 2)
plot(t, f(a_sol, b_sol,c_sol, d_sol, t), '-')
legend('data points','model fit')
model_parameters = [a_sol, b_sol,c_sol, d_sol
C=( 13.3446 *( 0.525 - 0.0004 ))/( 0.525 * 15.2)

Answers (1)

Dyuman Joshi
Dyuman Joshi on 22 Aug 2022
Moved: Voss on 22 Aug 2022
There is a close bracket sign (']') missing in your code
%2nd last line
model_parameters = [a_sol, b_sol,c_sol, d_sol]


Find more on Robotics System Toolbox 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!

Translated by