Effacer les filtres
Effacer les filtres

Replace part of string with variable

17 vues (au cours des 30 derniers jours)
Steven Taggart
Steven Taggart le 3 Déc 2017
Commenté : Steven Taggart le 3 Déc 2017
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

Réponse acceptée

Stephen23
Stephen23 le 3 Déc 2017
Modifié(e) : Stephen23 le 3 Déc 2017
str = sprintf('designPoint1.SetParameterExpression(parameter1, "%d")',dia);
execwbcommand(str)
  1 commentaire
Steven Taggart
Steven Taggart le 3 Déc 2017
That's brilliant.
Thanks Stephen!.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by