My Code For MatLab Is Saying, \"Unable To Perform Assignment Because The Left And Right Sides Have A Different Number Of Elements.\" For Line 11 In The For Loop. I Don't Know What I'm Doing Wrong. TFinal = 5; N = 1200; H=tFinal/N; T=linspace(0,t

匿名用户 最后更新于 2021-11-29 17:10 计算机类Computing

My code for MatLab is saying, "Unable to perform assignmentbecause the left and right sides have a different number ofelements." for Line 11 in the for loop. I don't know what I'm doingwrong.

tFinal = 5;
N = 1200;
h=tFinal/N;
t=linspace(0,tFinal,N+1); % type 'help linspace' to see how thisworks
x=zeros(1,N+1);

xExact= (10*(t+1).^(8))/((t+1).^(10)+9);

x(1) = 1; % setting the initial condition
for n=1:N
x(n+1) = x(n) + h * [(8*x(n))-(t+1)]-[(t+1)*x(n).^(2)];<---------------- I get the error msg here
end
plot(t,x,t,xExact,'--')
xlabel('t'); ylabel('y'); title('Problem 1!');

已邀请: