How to have a new line inside a string ?
142 次查看(过去 30 天)
显示 更早的评论
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 个评论
Stephen23
2021-5-20
"But, i don't know, how to use inside set(handles.parameterW.....)"
Change FPRINTF to SPRINTF
回答(2 个)
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),'
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!