Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

Reading Data from Excel Sheets in an Embedded Matlab function

1 view (last 30 days)
Hey Guys,
i am trying to read data from Excel sheets from within a matlab function in Simulink. M So far my code is:
function Leistung_Maschine_1 = function1(s_off,s_de,s_sb,s_op,s_w,time,data)
coder.extrinsic('assignin')
if s_off==1
Leistung_Maschine_1=0;
elseif s_de == 1
Leistung_Maschine_1=data(4);
elseif s_sb == 1
Leistung_Maschine_1=data(3);
elseif s_op == 1
Leistung_Maschine_1=data(2);
elseif s_w == 1
Leistung_Maschine_1=data(1);
else
disp('warning');
Leistung_Maschine_1=NaN;
assignin('base','Leistung_Maschine_1',Leistung_Maschine_1);
end
The problem is that, for example, when input s_op goes from 0 to 1 at simulation time 200, the 200th row of data(2) is given out as output but it should take the first value in row 1 and then starts to read out the values row after row. Also, at any given reentering of a statement at any simulation time, the output should start at the first row.
Does anyone know how i can fix my code?
Thank you very much!!

Answers (0)

This question is closed.

Community Treasure Hunt

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

Start Hunting!