Why isn't my code working because of delimeters?

1 次查看(过去 30 天)
>> N = 200;
h=tFinal/N;
t=linspace(0,tFinal,N+1); % type 'help linspace' to see how this works
z=zeros(1,N+1);
z(1)=1;
for n=1:N
z(n+1) = z(n) + h * ((10(t(n)+1)^8/((t(n)+1)^10.+9)));
end
for n=1:N
x(n+1) = x(n) + h * ((8(x(n))/(t(n)+1))-(t+1)*(x(n)^2);
end
plot(t,z,'--')
xlabel('t'); ylabel('y'); title('Look, ma! I solved it even better!');
z(n+1) = z(n) + h * ((10(t(n)+1)^8/((t(n)+1)^10.+9)));
Error: Invalid expression. When calling a function or indexing a variable, use parentheses.
Otherwise, check for mismatched delimiters.

采纳的回答

Steven Lord
Steven Lord 2021-2-26
10(t(n)+1) is not valid syntax in MATLAB. You need to explicitly perform the multiplication, 10*(t(n)+1).

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by