Import excel file into simulink

4 ビュー (過去 30 日間)
Mathubc khs
Mathubc khs 2012 年 8 月 9 日
I have a simulink file as in a part of that I have put a gain that takes a constant number (0.12) from my mfile to calculate the cost. I want to put an excel file instead of that number that has 48 values( the values might change every one hour). How I can import this excel file? Thanks a lot
  1 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 8 月 9 日
do you mean, while your simulink model is runing, you update the value by importing it ?

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

回答 (2 件)

TAB
TAB 2012 年 8 月 9 日
Simulink directly can not interact with excel file.
Use a m-file to read the data from excel and pass this data to gain block parameter using simulink API interface.
For example
% Read the data from excel
GainValue = Data stored in the cell
% Update the model's gain block value
set_param('BlockPath','Gain',num2str(GainValue))
  1 件のコメント
Kaustubha Govind
Kaustubha Govind 2012 年 8 月 9 日
You can use the XLSREAD command in MATLAB to read data from the Excel file.

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


Azzi Abdelmalek
Azzi Abdelmalek 2012 年 8 月 9 日
you can use an "intrpreted matlab fcn" block , with one constant input that does'nt matter, that pass through a 'zoh' block (with desired sample time : 3600s) and one output which will be the data updated.
function y=update_value(u);
y = xlsread('answer85.xlsx','a1:a1')
%in this case, you should run on real time which will possible only on normal mode

カテゴリ

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