How do I fix the "Subscript indices must either be real positive integers or logicals" error?
Info
This question is closed. Reopen it to edit or answer.
Show older comments
If you have the vectors r'(t) and r''(t), how can you plot curvature, K(t)=[normofthecrossproductofr'(t)andr''(t)]/[(normofr'(t))^3]? I've defined the x,y, and z components of r'(t) separately and did the same with r''(t), then defined r'(t) and a vector with said components. I then took the cross product of r'(t) and r''(t) using the "cross" function, defining the result as crossprod. I then entered the following:
curvature= @(W3) norm(crossprod(W3),2)/(norm(rprime(W3),2).^3);
figure
plot(w,curvature(w));
I had previously defined w as linspace(0,1). W3 is just a variable. When I run the code, I get this error: "Subscript indices must either be real positive integers or logicals." Is this because some of the results of sin and cos are negative? (sin and cos are part of the x, y, and z components of both r'(t) and r''(t).)
Answers (1)
Image Analyst
on 18 Sep 2015
0 votes
What is the value of w?
I think the FAQ explains it pretty well: http://matlab.wikia.com/wiki/FAQ#How_do_I_fix_the_error_.22Subscript_indices_must_either_be_real_positive_integers_or_logicals..22.3F
2 Comments
Mel Smith
on 18 Sep 2015
Image Analyst
on 18 Sep 2015
w3 will take on the value of w after it's passed in to your anonymous function. If you want to debug it, then convert it to a regular function so you can step into it and examine variables and program flow.
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!