Inserting doubles into the field of a struct
Mostra commenti meno recenti
Wondering if anyone knows how to insert a "double" into a struct. I was trying to use the following code to do it but I keep getting the error "Scalar structure required for this assignment."
Updating.GoodNews = Upda;
Risposta accettata
Più risposte (1)
Image Analyst
il 19 Set 2022
It's because Updating is a structure array so you need to put Upda into a new structure in the array. This works, where I append Upda to the existing array:
% Load mat files into structures.
s1 = load('Updating.mat')
s2 = load("Upda.mat")
% Extract variables from the structures.
Optimism_EMA_Updating = s1.Optimism_EMA_Updating
Upda = s2.Upda
% Append Upda as a new structure at the end of the structure array
Optimism_EMA_Updating(end+1).SubID = Upda
1 Commento
BA
il 19 Set 2022
Categorie
Scopri di più su MATLAB in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!