Data manipulation within CELL

3 views (last 30 days)
Yanis
Yanis on 20 Aug 2015
Edited: Yanis on 20 Aug 2015
Hi all,
Please bear with my as I am using MATLAB only for 5 days now.
I work with some fatigue test data. From the given data I have managed to create a TABLE with all the relevant data needed (called AllStrains, TABLE of 607 rows(no. of Strain gauges) x 28514 columns (time steps of recorded data)).
For each row (Strain gauge) I have to brake the data into segments based on the loading Turning Point (Every load case of the Test has a unique ID name, when the load case change, this is a Turning Point). The segments have been identified in the variable Loading_Turn_Points (total number of Turn Points 844).
Based on the above Turning Points, I have managed to create, what I call, "windowstrains", which is segments of data from the AllStrains TABLE indexed based on the Turn_Points.
windowstrains is a CELL(843 x 1), where 843 is the number of Turning Points -1. Each CELL element is a TABLE (607 x K), where 607 is the number of Strain Gauges, and K varies.
From the "windowstrains" I am trying to identify the Strain Turning Points, in order to do so I came up with the following algorithm:
---------------------------------------------------------------------------
1. Use diff() to create the difference of adjacent elms for each TABLE within the "windowstrains" CELL,
2. Then use sign()to get 1,0,-1 based o nthe diff().
3. Then use diff() again to get lots of zeros and 2,
4. Then I use find(), as the NON ZERO is my strain Turning point
5. Knowing the last, I should find the Time Step of the Strain Turning Point and compare it against the Loading Turnig Point, which I call it Lag.
6. Then I need the MODE of all the Lags (I should have 843 Lag values for each Strain Gauge, from which I need the MODE, and then 607 Lags (one for each Strain Gauge)).
7. Finally I need to save a csv file with 1 row and 2 columns. File name "fbin" and Lad (calculated above).
-------------------------------------------------------------------------------
Having describe what I need to do, my issues are:
1. I tried to do a LOOP:
%% Identify the Strains Turning Points per time window
for III=1:numel(Loading_Turn_Points)-1;
DiffDelta{III}=diff(windowstrains{III,1}(1,:));
end
But this ONLY gives my what I am after only for the first line (instead of 843 lines), when I tried to use the index III in this manner:
%% Identify the Strains Turning Points per time window
for III=1:numel(Loading_Turn_Points)-1;
DiffDelta{III}=diff(windowstrains{III,1}(III,:));
end
I get an ERROR "Attempted to access windowstrains.%cell(608,:); index out of bounds because size(windowstrains.%cell)=[607,25]."
I have tried to use the sign() for the DiffDelta CELL, but I get an ERROR "Undefined function 'sign' for input arguments of type 'cell'."
Any idea how to do the aforemention algorith in one loop?
2. Do you know how I can find the the Time Step of the Strain Turning Point? Step 5 in the algorithm
3. How do I save my calculated Lag in a CSV file?
4. Any general way of how to manipulated "nested" data within CELL in a TABLE format and how to use LOOP to populate CELLs and TABLEs, it would be great. I am a bit confused of CELL, TABLE definition when comes to coding.
Any help is welcome, thank you in advance.
Regards,
Yanis

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!