Matlab / Simulink Block Error
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Alessandro Rosner
le 30 Mar 2023
Réponse apportée : Fangjun Jiang
le 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 commentaires
Réponse acceptée
Fangjun Jiang
le 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur General Applications dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!