Data changing when I move it from one struct to another
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hello!
I'm writing a code which pulls data from one struct to a new struct (for organization purposes) from a directory.
For example I move it from something like
% new struct = old struct
b(1).A.eegData = data.eeg_Data
when I do this and call on b(1).A.eegData, I get an answer that looks like this [32 x 1234245] single that I can't view even in variable editor
while the original looks like a nice matrix of columns and rows containing data...
this also happens for smaller sets of data (eg. a 1 X 5 data set)
b(1).A.question1 = oldData.A.q1 (1:5);
I end up with [1 x 5] single instead of ans = 1 2 3 4 5
Am I doing something wrong, or is everything fine and I'm just not familiar with MATLAB to realize how to access my data
Thanks, ML
Risposte (2)
Muthu Annamalai
il 21 Giu 2013
I find your claim surprising, i.e. copying MATLAB data array from one variable to another, changes dimensions. This is very unlikely, and it is a bug if it is true.
For, example, the following code,
>> clear all
>> z=rand(5,100);
>> a(1).b.C = z;
>> size(a(1).b.C)
ans =
5 100
>> size(a(1).b.C)
works as expected, copying and preserves the data dimensions on uninitialized variables
If this is not the case, I am missing something about your data structures. What kind is data.eeg_data ? Is it a struct, cell-array, matrix, strings??
0 Commenti
Jan
il 23 Giu 2013
Modificato: Jan
il 23 Giu 2013
It depends on what exactly "I get an answer" means here. When the contents of a struct is displayed in the command window, such abbreviated information is shown.
c.d = rand(2,2)
displays:
c =
d: [2x2 double]
So I think the copy works well and only the display in the command window differs from your expectations.
0 Commenti
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!