Matlab / Simulink Block Error

10 ビュー (過去 30 日間)
Alessandro Rosner
Alessandro Rosner 2023 年 3 月 30 日
回答済み: Fangjun Jiang 2023 年 3 月 30 日
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

採用された回答

Fangjun Jiang
Fangjun Jiang 2023 年 3 月 30 日
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 件)

カテゴリ

Help Center および File ExchangeGeneral Applications についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by