How to change data in a cell array of doubles?

4 visualizzazioni (ultimi 30 giorni)
I have attached the variable that I am trying to change. The first column in each double is time. I would like to go through all the trials and fix the time so that it starts from 0, by doing time = time - 1
Time for the first trial (portion).
9.69938400000000
9.74050100000000
9.75054700000000
9.75911600000000
9.76805000000000
9.78226300000000
9.83225600000000
9.86755800000000
9.88683400000000
9.89537800000000
9.90186700000000
9.90746900000000
9.91257600000000

Risposta accettata

per isakson
per isakson il 31 Mar 2021
??? "doing time = time - 1" doesn't "fix the time so that it starts from 0"
Try this
>> load('trials.mat')
>> cac = cellfun( @(num) num-[num(1,1),0,0,0,0,0,0], trials, 'uni',false );
>> trials{1}(1:6,:)
ans =
9.6994 0 2673.3 0 4.93 0.41 600
9.7405 0 2673.7 0 10 0.41 600
9.7505 0 2674.1 0 40.91 0.82 600
9.7591 0 2674.5 0 47.96 1.23 600
9.7681 0 2674.9 0 46 1.64 600
9.7823 0 2675.3 0 28.91 2.05 600
>> cac{1}(1:6,:)
ans =
0 0 2673.3 0 4.93 0.41 600
0.041117 0 2673.7 0 10 0.41 600
0.051163 0 2674.1 0 40.91 0.82 600
0.059732 0 2674.5 0 47.96 1.23 600
0.068666 0 2674.9 0 46 1.64 600
0.082879 0 2675.3 0 28.91 2.05 600
>>
Or "doing time = time - 1"
>> cac = cellfun( @(num) num-[1,0,0,0,0,0,0], trials, 'uni',false );
  5 Commenti
per isakson
per isakson il 1 Apr 2021
I don't know how to answer.
MATLAB Onramp ...Learn the essentials of MATLAB through this free, two-hour introductory tutorial on commonly used features and workflows....
Do some experiments, e.g.
>> m = magic(3)
m =
8 1 6
3 5 7
4 9 2
>> m - [m(1,1),0,0]
ans =
0 1 6
-5 5 7
-4 9 2
Mirthand
Mirthand il 1 Apr 2021
Thanks! Your example made sense and I'll take a look at the tutorial!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices 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!

Translated by