フィルターのクリア

For-loop finding the difference between 7 different arrays

2 ビュー (過去 30 日間)
Jason
Jason 2023 年 10 月 2 日
編集済み: Image Analyst 2023 年 10 月 2 日
Hello,
I am having trouble figuring out how to get one refference array and subtract it versus 7 individual arrays. I have the code below which I can do for one array but I would like to loop it for the 7 arrays, t1-t7
Any help would be much appreciated
A(:,1) = t1(:,1)-tref(:,1); %Measuring the time difference between t1 and tref
  2 件のコメント
Jason
Jason 2023 年 10 月 2 日
Need to find the differences between all the elements
Matt J
Matt J 2023 年 10 月 2 日
How many columns do A, tref, and t1,...t7 have?

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

回答 (2 件)

Image Analyst
Image Analyst 2023 年 10 月 2 日
You can't loop it since you chose to have separately named 1-D arrays so you can just do it in 7 lines:
A(:,1) = t1(:,1)-tref(:,1); %Measuring the time difference between t1 and tref
A(:,2) = t2(:,1)-tref(:,1); %Measuring the time difference between t2 and tref
A(:,3) = t3(:,1)-tref(:,1); %Measuring the time difference between t3 and tref
A(:,4) = t4(:,1)-tref(:,1); %Measuring the time difference between t4 and tref
A(:,5) = t5(:,1)-tref(:,1); %Measuring the time difference between t5 and tref
A(:,6) = t6(:,1)-tref(:,1); %Measuring the time difference between t6 and tref
A(:,7) = t7(:,1)-tref(:,1); %Measuring the time difference between t7 and tref
  3 件のコメント
Jason
Jason 2023 年 10 月 2 日
Can A(:,1-7) be a for loop?
Image Analyst
Image Analyst 2023 年 10 月 2 日
編集済み: Image Analyst 2023 年 10 月 2 日
Instead of creating separately named arrays, you can create a single array T where you load up each column with the measurements that are now going into the individual vectors. Then you can simply do
A = T - tref;
Actually you don't even need a loop then.

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


Matt J
Matt J 2023 年 10 月 2 日
編集済み: Matt J 2023 年 10 月 2 日
T=cat(3, t1,t2,t3,t4,t5,t6,t7);
A = T-tref;

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by