Borrar filtros
Borrar filtros

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

3 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 1 de Oct. de 2023
[r(1,:),v(1,b)] = etc

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

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by