for j = 1:sz_idx1(1,1)
new_idx = idx1(j);
alt_i = alt{new_idx};
if ( alt_i== 'T')
A_T = count+1;
end
end

 採用された回答

KSSV
KSSV 2017 年 11 月 6 日
編集済み: KSSV 2017 年 11 月 6 日

1 投票

count = 0 ;
A_T = zeros([],1) ;
for j = 1:sz_idx1(1,1)
new_idx = idx1(j);
alt_i = alt{new_idx};
if ( alt_i== 'T')
A_T(count) = count+1;
end
end

4 件のコメント

vasudha jain
vasudha jain 2017 年 11 月 6 日
Empty matrix: 0-by-1
Undefined function or variable 'count'.
Error in testrun (line 32) A_T(count) = count+1;
it shows this error
KSSV
KSSV 2017 年 11 月 6 日
I though you have already define count before for loop..edited the answer.
vasudha jain
vasudha jain 2017 年 11 月 6 日
編集済み: vasudha jain 2017 年 11 月 6 日
Attempted to access A_T(0); index must be a positive integer or logical.
Error in testrun (line 31) A_T(count) = count+1;
i defined count before and it shows this error
Jan
Jan 2017 年 11 月 6 日
Replace "A_T(count) = count+1;" by
count = count + 1;
A_T(count) = count;

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

その他の回答 (1 件)

Jan
Jan 2017 年 11 月 6 日
編集済み: Jan 2017 年 11 月 6 日

0 投票

What about:
A_T = cumsum(strcmp(alt{idx1}, 'T'))
instead of the loops? Or perhaps you want:
A_T = sum(strcmp(alt{idx1}, 'T'))
or
A_T = 1:sum(strcmp(alt{idx1}, 'T'))

カテゴリ

ヘルプ センター および File ExchangeIntroduction to Installation and Licensing についてさらに検索

タグ

質問済み:

2017 年 11 月 6 日

編集済み:

Jan
2017 年 11 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by