Convert a vector into a structure array field

 Akzeptierte Antwort

Ray
Ray am 20 Okt. 2017

0 Stimmen

If struct s does not exist yet, you could use:
s = struct('x', num2cell(x));

3 Kommentare

bbb_bbb
bbb_bbb am 20 Okt. 2017
Bearbeitet: bbb_bbb am 20 Okt. 2017
Thank you. And if it does exist and I want to add a field x?
if x is the same length as the number of entries in the struct array s, then
temp = num2cell(x);
[s.x] = temp{:};
bbb_bbb
bbb_bbb am 20 Okt. 2017
Thanks!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Gefragt:

am 20 Okt. 2017

Kommentiert:

am 20 Okt. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by