Info

此问题已关闭。 请重新打开它进行编辑或回答。

Execute command syntax

3 次查看(过去 30 天)
K Kallerhoff
K Kallerhoff 2012-6-18
评论: Stephen23 2022-1-1
Hi, I need to change a value with and execute command like this
value = 1;
Execute(handles.server, 'test.a(1)=value')
but is only works, if the you type a number instead of value like this
Execute(handles.server, 'test.a(1)=1')
any suggestions?
Thanks Kay

回答(1 个)

Voss
Voss 2021-12-31
The character array 'test.a(1)=value' contains the word 'value' rather than the value of the variable "value". You can use sprintf() to get a variable number into a character array:
value = 1;
Execute(handles.server, sprintf('test.a(1)=%d',value))

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by