Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

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

1 vue (au cours des 30 derniers jours)
Arunachalam  D
Arunachalam D le 22 Mar 2015
Clôturé : MATLAB Answer Bot le 20 Août 2021
>> tau = 6:100; h = [2,3,4];
>> X = bsxfun(@rdivide,tau,h(:));
>> Y = X(rem(X,1)==0);
thank you

Réponses (1)

Geoff Hayes
Geoff Hayes le 22 Mar 2015
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.

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by