Clear Filters
Clear Filters

I keep on getting this error

1 view (last 30 days)
Charles Dizon
Charles Dizon on 15 Feb 2023
Answered: Sachin on 15 Feb 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

Answers (1)

Sachin
Sachin on 15 Feb 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

Categories

Find more on Interpolation 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!