Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Reading Data from Excel Sheets in an Embedded Matlab function

1 Ansicht (letzte 30 Tage)
Vincent Perner
Vincent Perner am 24 Nov. 2017
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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!!

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by