필터 지우기
필터 지우기

strrep with if condition

조회 수: 2 (최근 30일)
azar mzory
azar mzory 2014년 2월 17일
댓글: per isakson 2014년 2월 18일
s= strrep(origStr, oldSubstr, newSubstr)
% if
str1==strrep(str,'sport','1');
%else if
str2==strrep(str1,'art','2');
else if str3==strrep(str2,'art_u','3');
end
end
end
what is the error ? and how to use if condition with strrep ?? if u have more replacing ? art=2 'art_u' it's one word it will be 2_u it is error the output art=2 so to be art_u= 2_u is wrong should be 3 only how to solve ???
  댓글 수: 1
per isakson
per isakson 2014년 2월 18일
Why tagged: MATLAB C/C++ Graphics Library?

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

답변 (1개)

per isakson
per isakson 2014년 2월 18일
편집: per isakson 2014년 2월 18일
Is this the code you want to display?
if str1==strrep(str,'sport','1');
else
if str2==strrep(str1,'art','2');
else
if str3==strrep(str2,'art_u','3');
end
end
end
Comments:
  • Use strcmp instead of ==
  • In a week or two, you will find this code difficult to understand. It asks for bugs.
  • I cannot spot the error. Maybe, I don't get your question right. Provide data so that the code will run!
  댓글 수: 2
azar mzory
azar mzory 2014년 2월 18일
this code is error , not run u understand my question ??? art=2 , 'art_u' it's one word it will be 2_u it is error the output should be 3 only how to solve
per isakson
per isakson 2014년 2월 18일
No, I don't understand.

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

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by