i want to find the transpose of the matrix m but showing error. please can anyone help with the error

7 vues (au cours des 30 derniers jours)
function [m]=calc_m()
m_rot()=@(w) [0;cos(w);sin(w)];
Q=[0.4082,0.4082,-0.8165;0.7017,-0.7071,0;0.5774,0.5774,0.5774];
m()=@(w) Q*m_rot();
z=m.'

Réponse acceptée

Geoff Hayes
Geoff Hayes le 20 Mar 2019
Modifié(e) : Geoff Hayes le 20 Mar 2019
sadgun - can't you just do
z=m';
without the period? Though I'm not sure why you are setting this result to z since your function output parameter is m. Perhaps the above line of code should just be
m=m';
or the function signature should change to indicate that z is the output parameter.
Though perhaps this isn't the error? When I try to run your code, the first error is
m_rot()=@(w) [0;cos(w);sin(w)];
|
Error: An indexing expression on the left side of an assignment must have at least one
subscript.
Remove the brackets so that the assignment is just
m_rot = @(w) [0;cos(w);sin(w)];
The assignment for m will have the same problem so that should probably be
m = Q * m_rot(w);
where w is some value. Remember that m_rot is a function handle and so requires an input. Is this even correct though? Do you expect m to be a 3x1 matrix or should it be a rotated 3x3 matrix? Please clarify.
  9 commentaires
sadgun pulagam
sadgun pulagam le 21 Mar 2019
c11=169.9, c12=122.6, c44=76.2
these are the only inputs required i hope. other all are given inside the code itself.
Walter Roberson
Walter Roberson le 24 Mar 2019
Your calc_m_n returns function handles for m and n.
Then on line 33 you have
mat_uv(i,j)=mat_uv(i,j)+z(k)*mat_C(k,i,j,l,c11,c12,c44)*m(@(w)(l));
This calls the function handle m, passing in a function handle @(w) (l) . That is a function handle that, if executed, would accept any input and return the current value of l (lower-case L) as of the time the anonymous function was created.
The function handle that was returned for m involves Qinv and taking its parameter (w) and applying a matrix rotation to it by way of m_rot . That involves taking the cos() of the argument. But the argument is the function handle @(w)(l) and you cannot take the cos of a function handle.
It is not at all obvious why you use @(w)(l) as the argument to m on line 33, since on the next line, line 34, where you invoke the very similar n, you just pass in l instead of an anonymous function that encapsulates l like you do for m

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical 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!

Translated by