I keep on getting this error

1 vue (au cours des 30 derniers jours)
Charles Dizon
Charles Dizon le 15 Fév 2023
Réponse apportée : Sachin le 15 Fév 2023
File: solution.m Line: 3 Column: 46
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.
function [bc_nd,v_newton] = ndd(t,v,tdesired,2)
order=2;
v=v(2:2 + order);
t=t(2:2 + order);
%l=length(v);
%M = ones(l);
v=v';
t=t';
%for getting coeffs
%for i=1:l
% M(:,i)=(t'.^(i-1));
%end
%coeff=linsolve(M,v);
v0=v(1,1);
v1=v(2,1);
v2=v(3,1);
t0=t(1,1);
t1=t(2,1);
t2=t(3,1);
b2=(((v2-v1)/(t2-t1))-((v1-v0)/(t1-t0)))/(t2-t0);
b1=((v1-v0)/(t1-t0));
b0=v0;
coeff=[b0 b1 b2]';
% for getting soln
solution= b0+b1*(tdesired-t0)+b2*(tdesired-t0)*(tdesired-t1) ;
end

Réponses (1)

Sachin
Sachin le 15 Fév 2023
As per my understanding, you are getting this error because of you are passing an Integer value inside function declaration. Referring the following information might be of good help to you.
You can’t pass an Integer value as input to a function. That’s why you are getting syntax error.
Remove input "2" from function declaration. Change your function declaration as below -
function [bc_nd,v_newton] = ndd(t,v,tdesired)
For more information about MATLAB function declaration, refer to the following page
Regards
Sachin

Catégories

En savoir plus sur Interpolation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by