Data changing when I move it from one struct to another
1 次查看(过去 30 天)
显示 更早的评论
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
回答(2 个)
Muthu Annamalai
2013-6-21
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 个评论
Jan
2013-6-23
编辑:Jan
2013-6-23
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!