Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Could anyone help me to solve the issue.

1 回表示 (過去 30 日間)
jaah navi
jaah navi 2019 年 4 月 18 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I am having 5 users whose initial_position are generated by the code itself and gives the value as follows:
initial_position=1.7620e+06
initial_position=1.9911e+06
initial_position=1.8969e+06
initial_position=2.5384e+06
initial_position=2.5042e+06
All the 5 values are generated inside for loop in my code by running the loop 5 times.
Once the initial position is generated i need to find one common_position which is the maximum initial_position .
So i used the command ,common_position=max(initial_position) outside the for loop in order to find it
I got the result as common_position=2.5384e+06.
In the next step i need to use the expression of (common_position-initial_position)
so far in my code common_position is one which is calculated outside for loop, but initial_position is five which gets calculated inside for loop
Could anyone help me how can i use the expression of (common_position-initial_position) to generate 5 different values with respect to the difference of two positions.

回答 (1 件)

Torsten
Torsten 2019 年 4 月 18 日
編集済み: Torsten 2019 年 4 月 18 日
If "initial_position" is an array with 5 elements and "common_position" is a scalar, you can simply type
difference = common_position-initial_position
  2 件のコメント
jaah navi
jaah navi 2019 年 4 月 18 日
"initial_position" is an array with 5 elements generated inside the for loop
"common_position" is also an array with 1 element generated outside the for loop
If i use the command
difference = common_position-initial_position
outside the for loop it generates only one value.
but it need to be done with respect to 5 elements.
Could you please help me on this.
Torsten
Torsten 2019 年 4 月 18 日
編集済み: Torsten 2019 年 4 月 18 日
No, it will generate 5 values (if "initial_position" really is an array with 5 elements, as you claim).

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by