フィルターのクリア

How can I iterate the excel column data in Simulink (Matlab function block)?

3 ビュー (過去 30 日間)
jiyong park
jiyong park 2022 年 8 月 20 日
コメント済み: jiyong park 2022 年 8 月 24 日
I would like to import data one by one from excel(.xlsx) to Simulink.
With readtable or readcell, I can call a group of data.
But I would like to update the data in excel one by one automatically.
For example,
In loop :
I import the data in Excel A1, and I apply my function.
secondly the data in Excel A2, and I apply my function. A3, A4, A5..
In Python, I can use like this :
sheet1.cell(row=i+1, column= 1, value= x_in_data[0])
so that I can easily apply the iteration.
However, in Simulink Matlab function block, The readcell command is actually calling the string like this.
M = readcell('airlinesmall_subset.xlsx','Sheet','2007','Range','G2:I11')
What should I do?

採用された回答

Kartikay Sapra
Kartikay Sapra 2022 年 8 月 24 日
編集済み: Kartikay Sapra 2022 年 8 月 24 日
The following function 'xlscol' from File Exchange converts an integer to corresponding Excel column:
Then, you can iterate using(assuming first row is for column titles):
for i = 2:numOfRows
for j = 1:numOfColumns
cell_ij = xlscol(j) + string(i)
M = readcell('airlinesmall_subset.xlsx','Sheet','2007','Range', cell_ij + ":" + cell_ij)
end
end

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by