M-Function Block Simulink wrong output datasize.
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi, I have some problems with my Simulink (Simscape) M-function block. I would like to integrate a mathlab function that receives a voltage value as input and rounds it (Typ:double). This is used to search for a row from a table and the last four entries of this row are to be output in a variable.
However, I get the error:
Dimension 1 is fixed on the left-hand side but varies on the right ([1 x 1] ~= [:? x 1]).
Function 'Subsystem2/MATLAB Function' (#50.844.851), line 30, column 5:
"Trafo_1"
The Model Explorer is set to:
-suport variable-size arrrays
-saturate on intager overflow
-interpret output column vactors as one-dimensional data
The Values are all set to the type: double / Size:1 / Complexity:off
function [Trafo_1, Trafo_2, Trafo_3, Trafo_4] = Auswahl_Trafo(U)
%% Wahrheitstabelle für Betragstrafos
AnzahlZeilen = 81;
AnzahlSpalten = 4;
AnzahlKombinationen = 3^AnzahlSpalten;
Tabelle = zeros(AnzahlZeilen,AnzahlSpalten+1);
% Erstellen der Tabelle mit dem Argumenten -1, 0, 1
for i = 1:AnzahlZeilen
KombinationIndex = mod(i-1, AnzahlKombinationen) + 1;
Argumente = dec2base(KombinationIndex-1, 3, AnzahlSpalten) - '0';
Argumente(Argumente == 2) = -1;
Trafo = [0.2 0.6 1.8 5.4];
delta_U = 0;
for k = 1:4
delta_U = delta_U + Argumente(k) * Trafo(k);
end
delta_U = round(delta_U*100)/100;
Tabelle(i,:) = [delta_U Argumente];
end
Tabelle = sortrows(Tabelle,1,"descend");
%% Auswahl des geeigneten Tabelleneintrags
u_soll = round(U*5)/5;
z = find(Tabelle == u_soll);
Trafo_1 = Tabelle(z,2);
Trafo_2 = Tabelle(z,3);
Trafo_3 = Tabelle(z,4);
Trafo_4 = Tabelle(z,5);
end
0 Commenti
Risposte (1)
Andreas Goser
il 16 Mag 2023
I found this here which has a very similar error message and as there is code generation behind the scences with Simscape, this might be of help.
If that does not help, could you upload a reproduction example?
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!