I keep on getting this error
1 回表示 (過去 30 日間)
古いコメントを表示
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
0 件のコメント
回答 (1 件)
Sachin
2023 年 2 月 15 日
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
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!