Define a Matrix 3x3 using matlab
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
Azzi Abdelmalek
2016-5-20
There is no any variable A in your expression, := is not a Matlab operator, use instead = operator
回答(1 个)
Naga
2024-9-24
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!