Info

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

i wanna save the tau and h values in each iteration for which y values are calculated

1 回表示 (過去 30 日間)
Arunachalam  D
Arunachalam D 2015 年 3 月 22 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
>> tau = 6:100; h = [2,3,4];
>> X = bsxfun(@rdivide,tau,h(:));
>> Y = X(rem(X,1)==0);
thank you

回答 (1 件)

Geoff Hayes
Geoff Hayes 2015 年 3 月 22 日
Arunachalam - try using find to determine those rows and columns of X whose remainder (when divided by one) is zero. Something like
[rowIdcs, colIdcs] = find(rem(X,1)==0);
The rowIdcs would tell you the h and the colIdcs would tell you the tau. For example, if I run the above line, the first handful of row indices and column indices are
>> rowIdcs(1:5)
ans =
1
2
1
3
2
colIdcs(1:5)
ans =
1
1
3
3
4
The first two elements of colIdcs are 1 which corresponds to tau(1) (i.e. 6). The first two elements of rowIdcs are 1 and 2 which corresponds to 2 and 3 respectively. And this makes sense since 6 is evenly divisible by 2 and 3 but not by 4.

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by