How to change data in a cell array of doubles?

4 ビュー (過去 30 日間)
Graduate Student
Graduate Student 2021 年 3 月 31 日
コメント済み: Mirthand 2021 年 4 月 1 日
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

採用された回答

per isakson
per isakson 2021 年 3 月 31 日
??? "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 件のコメント
per isakson
per isakson 2021 年 4 月 1 日
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 2021 年 4 月 1 日
Thanks! Your example made sense and I'll take a look at the tutorial!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by