Create a Matrix from defined variables

Hey guys, I'm trying to create a matrix with combined math operations from already defined variables in the workspace but I always get an error. I would really appreciate some help :)
Variables :
c1=440
c2=250
r1= 50
r2=25
Matrix :
C=[c1*r1^2, c1*r1*r2, 0;
c1*r2*r1, c2+c1*c2^2, -c2;
0, -c2, c2]

2 件のコメント

Torsten
Torsten 2022 年 1 月 22 日
For me, it works fine.
What error message do you get ?
wissal zaher
wissal zaher 2022 年 1 月 22 日
That in order to define a function I have to use brackets but now it worked somehow.. I don't know why it was bugging

サインインしてコメントする。

 採用された回答

KSSV
KSSV 2022 年 1 月 22 日

0 投票

c1=440 ;
c2=250 ;
r1= 50 ;
r2=25 ;
C=[c1*r1^2, c1*r1*r2, 0;
c1*r2*r1, c2+c1*c2^2, -c2;
0, -c2, c2]
C = 3×3
1100000 550000 0 550000 27500250 -250 0 -250 250

1 件のコメント

wissal zaher
wissal zaher 2022 年 1 月 22 日
now it worked ! I don't know why I was getting an error earlier. Thanks :)

サインインしてコメントする。

その他の回答 (1 件)

Louis Alexander
Louis Alexander 2022 年 1 月 22 日

0 投票

this code is right.
c1=440
c1 = 440
c2=250
c2 = 250
r1= 50
r1 = 50
r2=25
r2 = 25
C=[c1*r1^2, c1*r1*r2, 0;
c1*r2*r1, c2+c1*c2^2, -c2;
0, -c2, c2]
C = 3×3
1100000 550000 0 550000 27500250 -250 0 -250 250
there could other reasons for the error.

1 件のコメント

wissal zaher
wissal zaher 2022 年 1 月 22 日
The error seems to be sorted out :) thanks

サインインしてコメントする。

カテゴリ

製品

リリース

R2021b

質問済み:

2022 年 1 月 22 日

コメント済み:

2022 年 1 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by