How to do excel read inside 'matlab function' block in simulink?

4 ビュー (過去 30 日間)
Badireddi  Baby Dora CB.EN.P2AEL16005
Badireddi Baby Dora CB.EN.P2AEL16005 2017 年 11 月 3 日
I need to read Excel data and compare it with data from simulink in a 'matlab function' block. Pleas let me know how can I do that as excel read is not allowed inside 'matlab function' block of simulink?
<<
>>
>>

回答 (1 件)

KL
KL 2017 年 11 月 3 日
編集済み: KL 2017 年 11 月 3 日
You may want to use
coder.extrinsic('xlsread')
before you call xlsread in your block.
Additional tip: if your excel file is not changing dynamically, don't do this. Import all your data into workspace first before you start your simulation. What you are doing now is importing data from that excel file again and again, during every timestep. Also there are advanced methods now to import data from an excel file. Read about readtable, it saves you much time by also reading the column names from your excel file too, instead of reassigning every column to multiple variables, you could simply say, vehicle_data.vehicle_no
  1 件のコメント
Badireddi  Baby Dora CB.EN.P2AEL16005
Badireddi Baby Dora CB.EN.P2AEL16005 2017 年 11 月 3 日
Hi KL, thank you for the response. I have modified the code as you said and I have used coder.extrinsic('xlsread') but no luck. My excel file is not changing dynamically, data remains same in a simulation. Please refer the screenshot for the error.

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

カテゴリ

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