Is there a way to make string without quotes?

조회 수: 21 (최근 30일)
Jung Woo Kim
Jung Woo Kim 2020년 1월 7일
댓글: Walter Roberson 2020년 1월 7일
MATLAB provides "shift + enter" to replace some words in a code.
But the problem is that "shift + enter" changes word in an entire code.
So, If I want to make change in a specific lines of code, not the entire code, what should I do?
At first, I thought I should make a function myself, but if I make a function that get code as argin, I found out it's not easy to convert it as a string, which is a lot easier form to make a change.
Any suggestions or recommendations would be welcomed.
Thx!

답변 (2개)

Walter Roberson
Walter Roberson 2020년 1월 7일
string() converts an input character vectors into a string object scalar, and converts a cell array of character vectors into a string object array.
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 1월 7일
In the Live Editor (but not yet in the regular editor) there is a way to select a rectangular block of text -- you hold down Alt as you move the mouse. Unfortunately you cannot do much with that selection; in particular I have not found any way to restrict search and replace to that section.

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


per isakson
per isakson 2020년 1월 7일
편집: per isakson 2020년 1월 7일
The title and the body-text of your question don't go together(?)
"shift + enter" replaces all occurences of a name in a "scope". There is no replace one at a time with confirmation.
I sometimes reuse short variable names like str in one scope. In that case I select str, Cntr+C, Cntrl+H, Cntrl+V in the replace field, edit the text in the replace field, Click Find and Replace as appropriate. Clumsy, yes, but I haven't found anything better.
Conclusion: don't reuse names!
IMO: Use the Matlab IDE for some time before you even think of improving it.
If you want to do Find and Replace in a several files see Find and Replace in Files

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by