Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Error: File: slopfield.m Line: 1 Column: 30 Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.

1 visualizzazione (ultimi 30 giorni)
Hi i am working on this code:
function [t,y] = eulode(dxdt,[0,0.4],2,0.1,varargin)
% input:
if nargin<4,error('at least 4 input arguments required'),end
ti = tspan(1);tf = tspan(2);
if ~(tf>ti),error('upper limit must be greater than lower'),end
t = (ti:h:tf)'; n = length(t);
if t(n)<tf
t(n+1) = tf;
n = n+1;
end
y = y0*ones(n,1); %preallocate y to improve efficiency
for i = 1:n-1 %implement Euler's method
y(i+1) = y(i) + dydt(t(i),y(i),varargin{:})*(t(i+1)-t(i));
end
But every time i run it i says "Error: File: slopfield.m Line: 1 Column: 30 Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses."
  1 Commento
Walter Roberson
Walter Roberson il 11 Mar 2020
Duplicated by https://www.mathworks.com/matlabcentral/answers/510225-error-file-slopfield-m-line-1-column-30-invalid-expression-check-for-missing-multiplication-ope

Risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by