How to properly access values in an array, within a cell array, within a struct?
Mostra commenti meno recenti
I have a struct called myStruct with 2 fields:
Field Value
light 4x2 cell
dark 4x2 cell
If I click on myStruct.light, I see the following arrays listed
2178x3860 double 2178x3860 double
2178x3860 double 2178x3860 double
2178x3860 double 2178x3860 double
2178x3860 double 2178x3860 double
and if I click on one of these cells, say myStruct.light{3,2}, I can then see the data in that cell's 2178x3860 array.
I would like to write a line in the Command Window that enables me to extract a range of values in myStruct.light{3,2}. Let's suppose that I want to calculate the mean of all values in a 2x4 array from the top left corner of myStruct.light{3,2}
If I enter
topleft=amberLED.light{3,2}(1:2,1:4)
in the command window, it seems to work ok. A 2x4 matrix called topleft is output:
topleft =
2356 2284 2347 2350
2273 2403 2288 2342
But when I then type:
mean = mean(topleft, 'all')
I get the following error message returned:
Index in position 1 exceeds array bounds (must not exceed 1).
Please can you advise me where I'm going wrong?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Structures in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!