How to have a new line inside a string ?

조회 수: 73 (최근 30일)
Vinothkumar Sethurasu
Vinothkumar Sethurasu 2021년 5월 20일
댓글: Vinothkumar Sethurasu 2021년 5월 20일
set(handles.parameterW,'string',{['stiffness = ',num2str(A),' Nm/deg,',' Damping = ',num2str(B),' Nm/(rad/s)']});
Current output:
stiffness = 1 Nm/deg, Damping = 0 Nm/(rad/s)
Output i required:
stiffness = 1 Nm/deg,
Damping = 0 Nm/(rad/s)
  댓글 수: 3
Vinothkumar Sethurasu
Vinothkumar Sethurasu 2021년 5월 20일
Thanks for your response.
The solution you have provided is working fine.
But, i don't know, how to use inside set(handles.parameterW.....)
Stephen23
Stephen23 2021년 5월 20일
"But, i don't know, how to use inside set(handles.parameterW.....)"
Change FPRINTF to SPRINTF

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

답변 (2개)

Girijashankar Sahoo
Girijashankar Sahoo 2021년 5월 20일
set(handles.parameterW,'string',{['stiffness = ',num2str(A)+newline+' Nm/deg,',' Damping = ',num2str(B),'
or
set(handles.parameterW,'string',{['stiffness = ',num2str(A),\n' Nm/deg,',' Damping = ',num2str(B),'
  댓글 수: 1
Vinothkumar Sethurasu
Vinothkumar Sethurasu 2021년 5월 20일
Thanks for your response.
The solution you have provided is not working.

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


Chandra Amma Palanisamy
Chandra Amma Palanisamy 2021년 5월 20일
Hi Vinothkumar,
It is my understanding that you want to insert a newline in a string. The example code is given below:
set(handles.parameterW,'string',{['stiffness = ',num2str(A),' Nm/deg,', newline,' Damping = ',num2str(B),' Nm/(rad/s)']});
Hope this helps.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by