i want to concatenate two variable but getting an error..."Names of fields in structure arrays being concatenated do not match. Concatenation of structure arrays requires that these arrays have the same set of fields"
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I want to concatenate two variables. first i loaded my data which is a matrix, to both variables then store particular part of variables in another variable and then concatenate them. Here is my code.
t=load('2');
v=load('3');
T.a =t(:,2:size(t,2));
c=v(:,2:size(v,2));
ans=cat(2,T.a,c);
Here '2','3' are my files.
but i am getting error...
Error using cat Names of fields in structure arrays being concatenated do not match. Concatenation of structure arrays requires that these arrays have the same set of fields.
Error in Untitled3 (line 5) ans=cat(2,T.a,c); i think becoz when i load data it stores in variables with different field names.
Plz provide some solution . i have to use it
2 Commenti
Risposte (1)
Jan
il 7 Dic 2016
A bold guess:
File2Data = load('2');
t = File2Data.t;
File3Data = load('3');
v = File3Data.v;
T.a = t(:, 2:size(t,2));
c = v(:, 2:size(v,2));
Reply = cat(2, T.a, c);
load replies a struct, not the values directly. You can check this manually.
3 Commenti
Jan
il 9 Dic 2016
The field names are defined by the names of the variables during saving. So they are not "random". But if you do not know the names:
Data = load(FileName);
Fields = fieldnames(Data);
for k = 1:length(Fields)
disp(Data.(Fields{k}))
end
Vedere anche
Categorie
Scopri di più su Structures in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!