Info
This question is closed. Reopen it to edit or answer.
I have a cell teste1 that's 1 column and many rows. Each row has a number between 0 and 5. I want to create teste2 cell with the same size that only compares the rows with 0 with some conditions.
1 view (last 30 days)
Show older comments
teste2 = teste1;
for k=2:(length(Preos2013S1)-1)
if teste2{k} == '0'
mask = strcmp(catracio1, 'low') & strcmp(catpreco, 'high');
teste2(mask) = {'A'};
mask = strcmp(catracio1, 'medium low') & strcmp(catpreco, 'medium high');
teste2(mask) = {'B'};
mask = strcmp(catracio1, 'medium') & strcmp(catpreco, 'medium');
teste2(mask) = {'C'};
mask = strcmp(catracio1, 'medium high') & strcmp(catpreco, 'medium low');
teste2(mask) = {'D'};
mask = strcmp(catracio1, 'high') & strcmp(catpreco, 'low');
teste2(mask) = {'E'};
else
teste2{k}='V';
end
end
If teste1(k) is 0, it should make those comparisons (2 string cells with the same size as all of these cells). But if none of those are satisfied, teste2(k) should be 0.
If teste1(k) is not 0, it can have a 'V'.
However, what is bugging me is that in some rows that are not 0 in teste1, teste2 is making the comparison anyway. So sometimes I have like C or another comparison result in teste2 that it should not be done. Can somebody please explain me what is wrong?!
0 Comments
Answers (0)
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!