フィルターのクリア

How to compare the the values of a 3-d dimensional array

3 ビュー (過去 30 日間)
Pallov Anand
Pallov Anand 2023 年 1 月 20 日
コメント済み: Pallov Anand 2023 年 1 月 20 日
Suppose I have a 3-D array, lets say, p(1,n,k) where n varies from 0 to t_span and t_span = 0:dt:80 (dt = 0.01) and k varies from 1 to 8.
Lets say I have an energy level denoted by E and decreasing at a constant rate in the following way:
E(1) = 6000;
E_lower = 4500;
E(n+1) = E(n) + dt * (-100);
What I want is, at the instant when E < E_lower, I want to compare the values between p(1,n,1) to p(1,n,8) and I want to know the index 'k' where the lowest value of p(1,n,k) is present at that particular instant "n".
Can anyone help me in this, how to proceed.
Thanks in advance.
  2 件のコメント
Dyuman Joshi
Dyuman Joshi 2023 年 1 月 20 日
As an index n must be a natural number, which is not the case here.
The smallest value of n or the value of n at the instant E < E_lower is, n = 1502, from the relationship you wrote.
Now we have to find the minimum of p(1,n,1:8). You can use the min for that, and obtain both the minimum value and the corresponding index.
Pallov Anand
Pallov Anand 2023 年 1 月 20 日
Thanks for your reply.
In this case, it might be 1502. But I want to write a code in such a way that, as soon as E < E_lower, then I need to compare the values between p(1,n,1:8) and get the minimum value as well as the index of the corresponding minimum value.

サインインしてコメントする。

採用された回答

Matt J
Matt J 2023 年 1 月 20 日
編集済み: Matt J 2023 年 1 月 20 日
n=find( 6000-100*t_span < E_lower,1);
[~,kmin]=min(p(:,n,:),[],3);
  3 件のコメント
Matt J
Matt J 2023 年 1 月 20 日
編集済み: Matt J 2023 年 1 月 20 日
Yes, it will. Did you check it?
Pallov Anand
Pallov Anand 2023 年 1 月 20 日
It worked.....thanks a lot again.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by