Attempted to access T(1,0); index must be a positive integer or logical.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have to create a toeplitz matrix without using the command. my teacher said to start off with something like this. Its for this problem Write a MATLAB routine (that is, a MATLAB function) that produces the finite difference solution ^u. Use a uniform discretization with x = 1=(n+1). (The input to the function should be n, and the output should be the approximate solution ^u.) Plot the approximate solution against the exact solution for n = 3, 7 and 15.
T(1,1)=1
T(1,2)=-1
for i=1:n-2
T(i,i-1)=1;
T(i,1)=-1;
T(i,i+1)=0;
end
It keeps giving me the error -Attempted to access T(1,0); index must be a positive integer or logical.- Anyone have a better idea of how to create this thing?
0 comentarios
Respuesta aceptada
Image Analyst
el 6 de Feb. de 2013
When i = 1 (your first iteration), then i-1 equals zero, so you'd have T(1,0). Zero is not allowed as a column number. Start your loop with i=2.
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!