%I have some indices
iVmn =[679,605,619,655,685,601];
iVmx=[225,403,403,403,403,259];
I want to count between each value iVmn and iVmx, eg 225-679, 403 to 605, so on. Is there any elegent way to perform this as I an unable use for loop?
I am doing this way.
W1=iVmx(1):iVmn(1);
W2=iVmx(2):iVmn(2);
W3=iVmx(3):iVmn(3);
W4=iVmx(4):iVmn(4);
W5=iVmx(5):iVmn(5);
W6=iVmx(6):iVmn(6);

 採用された回答

dpb
dpb 2020 年 7 月 5 日

0 投票

>> arrayfun(@(i1,i2) colon(i1,i2),iVmx,iVmn,'UniformOutput',0)
ans =
1×6 cell array
{1×455 double} {1×203 double} {1×217 double} {1×253 double} {1×283 double} {1×343 double}
>>

3 件のコメント

Akhtar Rind
Akhtar Rind 2020 年 7 月 6 日
Thanks dpb. If I convert cell arry to matrix, It goes to single row. How can I get 6 different colomns of above arry.
dpb
dpb 2020 年 7 月 6 日
Can't -- they're different lengths so can't put into an array. You can reorient the vectors in the cells or the cell array itself, but you can't make an array out of the result.
Akhtar Rind
Akhtar Rind 2020 年 7 月 6 日
Thank you.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeOperators and Elementary Operations についてさらに検索

質問済み:

2020 年 7 月 5 日

コメント済み:

2020 年 7 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by