Define a Matrix 3x3 using matlab

5 Ansichten (letzte 30 Tage)
Nemo
Nemo am 20 Mai 2016
Beantwortet: Naga am 24 Sep. 2024
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 Kommentar
Azzi Abdelmalek
Azzi Abdelmalek am 20 Mai 2016
There is no any variable A in your expression, := is not a Matlab operator, use instead = operator

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Naga
Naga am 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];

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by