Adding a wave to a three body problem

2 ビュー (過去 30 日間)
James Browbank
James Browbank 2022 年 5 月 15 日
回答済み: Maneet Kaur Bagga 2023 年 9 月 20 日
I currently have a three body problem where the positions, P, of all 3 bodies are stored in one 3x3 matrix. I would like to add a 4th item, a wave, to my model.
I have tried adding it to this array however, due to the wave being an array in itself this won't generate the range in the y axis that I need to make calculations.
Is there a way I can inbed a array into my position matrix or are there any other solutions I could consider?
%current position matrix
P = [ 0 0 0
5 0 0
2.5 4.330 0];
%ideal position matrix (where x= -5,5)
P = [ 0 0 0
5 0 0
2.5 4.330 0
x -10 0];

回答 (1 件)

Maneet Kaur Bagga
Maneet Kaur Bagga 2023 年 9 月 20 日
Hi James,
According to the MATLAB documentation,
It is generally not feasible for the elements of a matrix(2D array) to be matrices themselves. Matrix in MATLAB contain homogeneous data. However, an alternative approach could be using a cell array to transform the current position matrix into an ideal position matrix by referring to the code below:
P = cell(4,3);
P = {0 0 0;5 0 0;2.5 4.330 0;[-5,5] 10 0}
P = 4×3 cell array
{[ 0]} {[ 0]} {[0]} {[ 5]} {[ 0]} {[0]} {[2.5000]} {[4.3300]} {[0]} {[ -5 5]} {[ 10]} {[0]}
Please refer to the following cell array documentation:
Hope this helps!
Thank You
Maneet Bagga

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by