フィルターのクリア

Info

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

How to update a value in different raw after performing validity check at one raw?

1 回表示 (過去 30 日間)
KenL
KenL 2016 年 10 月 3 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have a file containing 5 raws including the titles and 3 columns. After performing a validity check for value at raw(2,2), I will need to update the raw(2,3) with another value. However, I failed to do so. Please advise.
  4 件のコメント
KenL
KenL 2016 年 10 月 3 日
file={'No','Question','Length';'1','how are you?','';'2','What is your name?','';'3','Where do you stay?','';'4','How old are you?',''}
I want to figure out the length for all the text columns.
KenL
KenL 2016 年 10 月 4 日
Pls advise.

回答 (2 件)

Guillaume
Guillaume 2016 年 10 月 4 日
If I understood correctly
file = {'No','Question','Length';'1','how are you?','';'2','What is your name?','';'3','Where do you stay?','';'4','How old are you?',''};
file(2:end, 3) = cellstr(num2str(cellfun(@numel, file(2:end, 2)))
will work. Or if you have R2016b:
file = {'No','Question','Length';'1','how are you?','';'2','What is your name?','';'3','Where do you stay?','';'4','How old are you?',''};
file = string(file);
file(2:end, 3) = file(2:end, 2).strlength;

Andrei Bobrov
Andrei Bobrov 2016 年 10 月 4 日
編集済み: Andrei Bobrov 2016 年 10 月 4 日
file(2:end,3) = cellfun(@(x)sprintf('%d',numel(x)),file(2:end,2),'un',0)

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by