Define a Matrix 3x3 using matlab
5 views (last 30 days)
Show older comments
I'm tryin to define a 3x3 matrix using matlab but I get an error: Undefined function or variable 'A'. Here's my code:
J := matrix([[-(l1+q2)*sind(q1)-l3*sind(q1+q2), cosd(q1), -l3*sind(q1+q3)], [(l1+q2)*cosd(q1)+l3*cos(q1+q3), sind(q1), l3*cosd(q1+q3)],[1,0,1]]);
Can someone please help with the syntax?
1 Comment
Azzi Abdelmalek
on 20 May 2016
There is no any variable A in your expression, := is not a Matlab operator, use instead = operator
Answers (1)
Naga
on 24 Sep 2024
Hello Nemo,
It looks like there are a few syntax issues in your MATLAB code. As Azzi mentioned MATLAB does not use := for assignment; instead, it uses =. Additionally, the function to define matrices in MATLAB is simply using square brackets [] without the 'matrix' keyword. Here is
The corrected MATLAB code:
J = [-(l1 + q2) * sind(q1) - l3 * sind(q1 + q2), cosd(q1), -l3 * sind(q1 + q3);
(l1 + q2) * cosd(q1) + l3 * cosd(q1 + q3), sind(q1), l3 * cosd(q1 + q3);
1, 0, 1];
0 Comments
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!