replace all cells in 1 cell array that contain one specific value with a string

Hi, I've got a 5242488*19 cell array. all cells either contain 1 or 0. I need to replace the 1 in all cells with the string '10 -10 0'. I need to replace the 0 in all cells with the string '-10 10 0', I've got an index denoting all the cells containing 1 and one index denoting all the cells that contain 0. But I can't get the program to change the values. May sound silly, but maybe I'm confusing the brackets.
Couldn't find a loop solution, either.
Thx.

댓글 수: 1

It would be easier to answer, if you post, what you have done so far as code. Then we could use your notation and the risk of creating new misunderstanding would be smaller.

댓글을 달려면 로그인하십시오.

 채택된 답변

Jan
Jan 2011년 10월 14일
C = {0, 1; 1, 0; 1, 1};
index = cell2mat(C);
Pool = {'-10 10 0', '10 -10 0'};
Result = Pool(index + 1);

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by