Attempted to access T(1,0); index must be a positive integer or logical.
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
Image Analyst
on 6 Feb 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.
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!