change the value of a data structure field

26 views (last 30 days)
Trop Trader
Trop Trader on 6 Apr 2024 at 20:54
Edited: Stephen23 on 7 Apr 2024 at 6:18
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

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 6 Apr 2024 at 21:26
Edited: Fangjun Jiang on 6 Apr 2024 at 21:28
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'

More Answers (0)

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!