Matlab / Simulink Block Error
37 views (last 30 days)
Show older comments
Alessandro Rosner
on 30 Mar 2023
Answered: Fangjun Jiang
on 30 Mar 2023
Hey guys,
I don't understand which parameters are wrong. I want to simulate a isothermal expansion. Here I got this Error:
A valid state attribute should be a non-missing string array, a character vector, a cell array or a valid MATLAB structure.
Component:Simulink | Category:Block error
This is my Matlab Code:
clc, clearvars
% Parameter deklarieren
V0 = 0.001; % Anfangsvolumen [m^3]
Q = 1; % Heizleistung [W]
Rs = 287.058; % spezifische Gaskonstante für Luft [J/(kg*K)]
T = 293.15; % Anfangstemperatur [K]
p = 100000; % Anfangsdruck [Pa]
Tsim = 200; % Simulationsdauer [s]
h = 0.1; % Schrittweite [s]
% Simulink-Modell laden
open_system('isotherm_expansion');
% Anfangsbedingungen setzen
set_param('isotherm_expansion/Integrator', 'InitialCondition', '0.001');
set_param('isotherm_expansion/Gain', 'Gain', num2str(Q/(Rs*T)));
% Simulationszeit konfigurieren
set_param('isotherm_expansion', 'StopTime', num2str(Tsim));
% Simulation ausführen
sim('isotherm_expansion');
% Simulationsergebnisse speichern
t = V.time; % Zeitvektor
v = V.signals.values; % Volumenvektor
% Ergebnisse plotten
plot(t,v);
title('Volumenänderung während einer isothermen Expansion');
xlabel('Zeit [s]');
ylabel('Volumen [m^3]');
My Blocks + Parameters:
Integrator:
Sum:
Gain:
Hope that you can help me.
Thanks a lot! Cheers,
Alessandro
0 Comments
Accepted Answer
Fangjun Jiang
on 30 Mar 2023
The "State Name" parameter of the Integrator block, where you set as "V0", should not be a value. It is a "Name". It should be something like " 'Anfangsvolumen' ", like e.g. 'Position' in the dialog prompt.
0 Comments
More Answers (0)
See Also
Categories
Find more on Event Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!