필터 지우기
필터 지우기

Unable to perform assignment because the left and right sides have a different number of elements.

조회 수: 3 (최근 30일)
For this code im trying to use lagrange coeficients to map out the orbit of a body. In order to do this, i start with a 1x3 vector r0 and a 1x3 vector v0, put them into the function called "Lagrange_Method_Solver", and it outputs 2 new 1x3 vectors called r and v. In order to continue to solve, you need to take those new r and v values that you just found, plug them into the old r0 and v0 inputs, and repeat the proccess until your orbit is complete. I have made the function and it outputs correct r and v values, but when i add the "for" and try to loop it, the issues comes up where [r(1),v(1)] is using a 1x1 and (r0,v0) is using a 1x3. How do i make it so when i try to plug r and v back into the function in order to loop it, it is input as a 1x3 array and not a 1x1 with 3 numbers in it? This is atleast from my understnading, i could be misunderstanding the problem entirely. I also read something about using a cell array but ihave no idea how to implement that.
Here is the function i am solving:
This is how im calling the function and attempting to loop:
This is the error that appears:
Any help would be greatly appreciated. I am still very much a beginner with matlab so i apoligize for any lack of clarity.

채택된 답변

Walter Roberson
Walter Roberson 2023년 10월 1일
[r(1,:),v(1,b)] = etc

and pass in r(i-1,:), v(i-1,:)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by