I keep getting this error:
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
clear all
M=input('Enter M =')
N=input('Enter N=')
r=input('Enter r=')
f=input('Enter f=')
L=pi;
h=L/M;
%------&------------------------&------------------------------&-----------------*
%Ne kete program behet zgjidhja numerike e nje problemi diferencial valor
%me shuarje kufitare.Metoda e perdorur eshte ajo e tipit te
%karakteristikave .Ajo shfrytezon rrjetin specifik te nyjeve qe gjenerojne
%kurbat karakterisitke te ekuacionit si dhe vecorite e kushteve
%fillestare-kufitare te problemit
%-------&-----------------------&---------------------------------&--------------*
for i=1:M+1
x(i,1)=i*h;
u(i,1)=sin(x(i,1));
xu(i,1)=cos(x(i,1)); %derivati ne lidhje me x;
tu(i,1)=cos(x(i,1)); %derivati ne lidhje me t;
end
for j=1:N+1
for i=2:M
xu(x(i,j+1))=1/2*[cos(x(i,j))+cos(x(i-1,j))+cos(x(i,j))-cos(x(i-1,j))]+h/8*[r*(cos(x(i,j))-(1/f)*(cos(x(i,j))))-r*(cos(x(i-1,j))-(1/f)*(cos(x(i-1,j))))];
tu(x(i,j+1))=1/2*[cos(x(i,j))-cos(x(i-1,j))+cos(x(i,j))+cos(x(i-1,j))]+h/8*[r*(cos(x(i,j))-(1/f)*(cos(x(i,j))))+2*(r*(cos(x(i,j+1))-(1/f)*(cos(x(i,j+1)))))+r*(cos(x(i-1,j))-(1/f)*(cos(x(i-1,j))))];
u(x(i,j+1))=1/2*[sin(x(i-1,j))+sin(x(i,j))]+h/8*[cos(x(i-1,j))-cos(x(i,j))+cos(x(i-1,j))+2*cos(x(i,j+1))+cos(x(i,j))];
end
end
------------------------------------------------------------------------------
??? Index exceeds matrix dimensions.
Error in ==> MOC at 30
xu(x(i,j+1))=1/2*[cos(x(i,j))+cos(x(i-1,j))+cos(x(i,j))-cos(x(i-1,j))]+h/8*[r*(cos(x(i,j))-(1/f)*(cos(x(i,j))))-r*(cos(x(i-1,j))-(1/f)*(cos(x(i-1,j))))];
0 commentaires
Réponse acceptée
Walter Roberson
le 3 Juin 2013
You initialize x(:,1) but you use x(:,j) with j > 1
2 commentaires
Walter Roberson
le 4 Juin 2013
You need to assign values to x(i,j) at some point, but I do not know where would be appropriate. My guess would be that it should be done before the "for j" loop, instead of only initializing x(i,1)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Encryption / Cryptography dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!