Error:Field and value input arguments must come in pairs
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (1)
NALLARASU KRISH
le 23 Déc 2022
0 votes
When you create or modify struct in Matlab, you may ensure that the number of fields be in even number.
Catégories
En savoir plus sur Structures dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!