change the value of a data structure field

3 次查看(过去 30 天)
it's possible to avoid loop? thank
class(app.Sis)
ans =
'struct'
Sis(1).Val
ans =
'l'
h=size(Sis,2);
for i=1:h
Sis(i).Val='kkk';
end

采纳的回答

Fangjun Jiang
Fangjun Jiang 2024-4-6
编辑:Fangjun Jiang 2024-4-6
s(3).Val='1';
s.Val
ans = [] ans = []
ans = '1'
[s.Val]=deal('2')
s = 1x3 struct array with fields:
Val
s.Val
ans = '2'
ans = '2'
ans = '2'

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by