필터 지우기
필터 지우기

Replace part of string with variable

조회 수: 17 (최근 30일)
Steven Taggart
Steven Taggart 2017년 12월 3일
댓글: Steven Taggart 2017년 12월 3일
Hello,
I have a function that receives an input (double), and I would like to replace part of a string with this number. The string is used for controlling another program, I would like to be able to replace the '14' with whatever number is passed to the function. I have been trying sub and replace but having little luck. Any suggestions on how best to achieve this?
Cheers
Steven.
function wbinput (dia)
execwbcommand('designPoint1.SetParameterExpression(parameter1, "14")');
end

채택된 답변

Stephen23
Stephen23 2017년 12월 3일
편집: Stephen23 2017년 12월 3일
str = sprintf('designPoint1.SetParameterExpression(parameter1, "%d")',dia);
execwbcommand(str)
  댓글 수: 1
Steven Taggart
Steven Taggart 2017년 12월 3일
That's brilliant.
Thanks Stephen!.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by