필터 지우기
필터 지우기

string joining without inverted commas and variable pass in string.

조회 수: 2 (최근 30일)
Paramjit Yadav
Paramjit Yadav 2024년 6월 6일
댓글: Stephen23 2024년 6월 6일
Hello everyone,
I am trying to join two strings and then I need to have it as character and remove all the single or double inverted commas on it.
Also, how to give one input as variable.
for example.
"obj.UI.knob_" + "4" + ".Value"
here "4" is variable and it should change.
At the end I should have- obj.UI.knob_4.Value and not "obj.UI.knob_4.Value" i.e I dont need inverted commas.
I request to pleae help in removing the inverted commas, and how to pass variable in it.
Thanking you,
Kind regards
  댓글 수: 1
Stephen23
Stephen23 2024년 6월 6일
"I request to pleae help in removing the inverted commas"
The "inverted commas" are not a part of the text, there are purely an artifact of the display routine. You are confusing how data is displayed in the command window with the data itself.

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

답변 (2개)

Deepak Gupta
Deepak Gupta 2024년 6월 6일
That's how strings will be displayed if you directly type variable holding the string in command window. If you just want to display string without commas, you can use disp function.
  댓글 수: 1
Stephen23
Stephen23 2024년 6월 6일
+1 Works for me:
num = 23;
disp(['out = obj.Knob' ,num2str(num), '.Value'])
out = obj.Knob23.Value

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


Matlab Pro
Matlab Pro 2024년 6월 6일
1st - use a single 'postrophe': ' instead of "
I have created a simple function that returnes the value of a Knob.
Add this function to your app
function out = ret_Knob_value(obj,num)
eval(['out = obj.Knob' ,num2str(num), '.Value;']);
Good luck!
  댓글 수: 1
Paramjit Yadav
Paramjit Yadav 2024년 6월 6일
Thank you so much for answering.
But I need 'out = obj.Knob' ,num2str(num), '.Value' to displayed as
out = obj.Knob4.Value. without inverted comas. Since I have prepared app without using app tool bar. Hence I need it to change values.
Here I get 'out = obj.Knob4.Value' i.e with single inverted commas. I dont wantt this single inverted commas as well in the end.
Thanking yoiu,
Kind regards

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

카테고리

Help CenterFile Exchange에서 Switches and Breakers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by