1

In the M-file "matrixT.m", i wrote the function matrixT to generate a n*3 matrix like that

function T=matrixT(alpha,n)
T=zeros(3,n);
for i=1:n
    T(1,i)=cos(alpha(i));
    T(2,i)=sin(alpha(i));
    T(3,i)=sin(alpha(i)-i*pi/2);
end

Then i use it in my main M-file

alpha=sym('alpha');
V=subs(hessian(det(matrixT(alpha,3)),alpha),alpha,alpha0);

but there are many error. Can you help me to fix this?

1 Answer 1

3

I believe your problem lies in the assignment: T(1,i)=cos(alpha(i));. You have assigned alpha to be a symbolic variable, but then you try to assign it to an array of doubles and MATLAB complains. Is it possible to evaluate the value of alpha before attempting to place it inside the array T?

Sign up to request clarification or add additional context in comments.

6 Comments

How can I assign an array of variables for alpha?
You'll probably want to use your subs function earlier to substitute a real value for alpha before you try to put it into the T array.
the problem is, i must assign the vector alpha (n-dimensional) and take the hessian? can i do it? Could you make an example for me?
alpha is not a vector, it's a symbolic variable. If you have to calculate the Hessian multiple times using different values of alpha, I would recommend placing the Hessian calculation inside a for loop, and in each loop iteration set the value of alpha and then calculate what you want.
If you only have one value for alpha, then don't make it a symbolic variable. Just use the value of alpha to make your T matrix and everything should be fine. However, if you have multiple values for alpha, you'll need to evaluate V in a loop because it will take on different values for different values of alpha.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.