avoid for loop in a specific code
이전 댓글 표시
Could anyone help me if there is any way to avoid for loop in the following code: Both Target and predicted_target are vectors with n rows and one column.
new_classes=cell(size(Target,1),1);
for i=1:size(Target,1)
if (strcmp(predicted_target(i),Target{i}))
new_classes{i}=strcat('c',Target{i});
else
new_classes{i}=strcat('E',Target{i});
end
end
댓글 수: 3
the cyclist
2019년 8월 10일
Can you upload your data (or a representative sample) in a MAT file?
MA
2019년 8월 10일
Bruno Luong
2019년 8월 10일
편집: Bruno Luong
2019년 8월 10일
@MA: You change cell array to char array, you change variable name predicted_target to predicted_t.
Please don't do that if you want getting exactly the code that works
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!