replacing some string variables by others; a small problem

1 回表示 (過去 30 日間)
antonet
antonet 2013 年 3 月 13 日
Dear all,
i have the following problem
I want to replace the elements of EER with the corresponding elements from EER1
where
EER={datebeg '01/01/2009' '01/07/2009' };
EER1={'1' '2' '3' '4'};
and
datebeg =
'01/11/2009'
Unfortunately the '01/11/2009' is not replace by '1' and I need
to maintain the code as it is; that is using datebeg in EER instead of
'01/11/2009'
Is there a way of doing this?
I use the following code for the replacement
isAW = strcmp(raw(:, 1), 'EE');
AWtext = raw(isAW, 8); % Only the AW rows
for k = 1:numel(EER)
AWtext(strcmp(AWtext, EER{k})) = {EER1{k}};
end
new(isAW) = AWtext;
thanks
  2 件のコメント
Jan
Jan 2013 年 3 月 13 日
Please post the code you use for replacing the strings. It is confusing, that EER and EER1 have a different number of elements.
antonet
antonet 2013 年 3 月 13 日
編集済み: antonet 2013 年 3 月 13 日
thanks Jan. sorry for my mistake. this is the code I used
EER={datebeg '01/01/2009' '01/07/2009' };
EER1={'1' '2' '3' };
isAW = strcmp(raw(:, 1), 'EE');
AWtext = raw(isAW, 8); % Only the AW rows
for k = 1:numel(EER)
AWtext(strcmp(AWtext, EER{k})) = {EER1{k}};
end
new(isAW) = AWtext;
where raw is a matrix
With thte above code I replace all the elements that I want apart from the first one

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

採用された回答

Walter Roberson
Walter Roberson 2013 年 3 月 13 日
containers.map perhaps ?
  1 件のコメント
antonet
antonet 2013 年 3 月 13 日
Sorry I am asking but how does this function fit to the above example. Could you display some code
many thanks

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResampling Techniques についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by