if statement problem with excel file

조회 수: 1 (최근 30일)
federico
federico 2013년 11월 4일
편집: Niklas Nylén 2013년 11월 5일
hi to everyone!i don't know how to manage this problem: i have two block functions that have to run in function of an Excel file. This file is a vector that for every hour of the year shows a 1 or 2. If the hour is connected to a 1, one block function has to work otherwise for the other one in case of a 2. How i can manage this?thank you very much for your support!

채택된 답변

Niklas Nylén
Niklas Nylén 2013년 11월 4일
The first step would be to import the data from the excel file into Matlab by using the xlsread function. Then reformat the data to be readable by a 'From workspace' block in Simulink (which I assume we are talking about when you write "block function").
  댓글 수: 2
federico
federico 2013년 11월 4일
yeah i'm working in Simulink and i've done it. It is a .mat vector 2X8760, where first row are the hours/year while the second row is the 1 or 2 sequence. I linked it in a if-then-else block, based on the sequence (condition is u(1)>1) and connected to two subsystem but it does not recognized the conditions. The subsytems both work despite the "if" condition. How i can resolve it?Thank you for the help!
Niklas Nylén
Niklas Nylén 2013년 11월 5일
편집: Niklas Nylén 2013년 11월 5일
Depending on what you want to accomplish, an if-block is possibly not the right choice for you. Here is how you use if/else-blocks: http://www.mathworks.se/help/releases/R2013b/simulink/slref/if_block_floating_point_model.png
If you just want to enable or disable subsystems, you should probably have a look at enabled subsystems: http://www.mathworks.se/help/simulink/ug/enabled-subsystems.html

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by