Error:Field and value input arguments must come in pairs
Mostra commenti meno recenti
I have a code with a structure array a which is initialized as follows
if true
a=struct([]);
for i=1:(v_max+5)/5
a(i).v_low=0;
a(i).v_up=0;
a(i).t_cat=0;
a(i).idlecat_p=0;
%Assign value to each field in the structure array.
end
end
Now I'm trying to make another structure array b with same fields as of a
if true
f=fieldnames(a);
b=struct(f{:},0);
end
Till now I didn't have the field idlecat_p but soon as I added that to a, I'm getting the following error:
if true
Error using struct
Field and value input arguments must come in pairs.
Error in Code (line 373)
b=struct(f{:},0);
end
It's like whenever I'm adding a new field to a, the above error is coming at the same line
Risposta accettata
Più risposte (1)
NALLARASU KRISH
il 23 Dic 2022
0 voti
When you create or modify struct in Matlab, you may ensure that the number of fields be in even number.
Categorie
Scopri di più su Structures in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!