How can I iterate the excel column data in Simulink (Matlab function block)?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
jiyong park
el 20 de Ag. de 2022
Comentada: jiyong park
el 24 de Ag. de 2022
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?
0 comentarios
Respuesta aceptada
Kartikay Sapra
el 24 de Ag. de 2022
Editada: Kartikay Sapra
el 24 de Ag. de 2022
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
Más respuestas (0)
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!