Multiplying two columns from two excel sheets in MATLAB

2 ビュー (過去 30 日間)
Kefayet Ullah
Kefayet Ullah 2020 年 10 月 20 日
コメント済み: Ameer Hamza 2020 年 10 月 20 日
Hello there,
I have two excel files. In both files, I have two coumns in each file. In one column the values are time values(x-axis) and the other column is my data(y-axis) at corresponding time values. This scenario is true for both the files. The time data range is same in both the coumns of both the excel files. Now I want to multiply the the data values (in y-asis) of both files with each other keeping the time range as it is. I mean, I just want to multuply the y-columns (or 2nd) column of both the excel files with each other.
It would be great if anyone could provide a MATLAB code for this operation. Any kind of help would be highly appreciated.
Thank you

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 10 月 20 日
If both files have same number of rows
data1 = readmatrix('file1.xlsx');
data2 = readmatrix('file2.xlsx');
out = data1(:,1).*data2(:,1);
If they have different number of rows then use interp1() first to make them equal.
  2 件のコメント
Kefayet Ullah
Kefayet Ullah 2020 年 10 月 20 日
Great. It worked.
Thank you
Ameer Hamza
Ameer Hamza 2020 年 10 月 20 日
I am glad to be of help!!!

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

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by