Implementing vectorial equation with matrix as variable

I have the following equation I want to implement for an exercise.
Am facing the following problems that I have not been able to overcome:
  • The equation contains two equal signs which MatLab does not accept.
  • when taking away one of the equal signs ML says there are too many output. Also, putting a semicolon between a(i) and b(i) causes errors.
a = zeros(1, 5);
b = zeros(1, 5);
c = 3.1415;
D = [0 1; -3.5 -0.921];
a0 = 45;
b0 = 31;
i = 2; %would later be variable
[a(i), b(i)] = [a0; b0]*c^(D*i)
Dividing the vector causes ML to say that the left and the right side have a different number of elements:
a(i) = a0*c^(D*i)
Unable to perform assignment because the left and right sides have a different number of elements.
Perhaps it simply isn't possible. If that is the case, confirming that would be appreciated.
Any help or tips in regards to implementing this equation would also be greatly appreciated.

 채택된 답변

Torsten
Torsten 2022년 6월 7일
편집: Torsten 2022년 6월 7일
c^(D*i) is a 2x2 matrix. Thus [a0;b0]*c^(D*i) is not defined.
Maybe you mean c^(D*i)*[a0;b0] or [a0,b0]*c^(D*i) ? I implemented the latter.
c = pi;
D = [0 1; -3.5 -0.921];
a0 = 45;
b0 = 31;
v0 = [a0,b0];
i = 2;
v = v0*expm(log(c)*D*i);
a = v(1)
a = 5.9402
b = v(2)
b = -10.7458

댓글 수: 3

I see, thank you. I meant the former: c^(D*i)*[a0;b0]
How would one go about implementing that one? Simply changing v0 gives me dimension errors.
c = pi;
D = [0 1; -3.5 -0.921];
a0 = 45;
b0 = 31;
v0 = [a0;b0];
i = 2;
v = expm(log(c)*D*i)*v0;
a = v(1)
a = -16.7576
b = v(2)
b = 22.2026
Thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기

제품

릴리스

R2022a

질문:

2022년 6월 7일

댓글:

2022년 6월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by