Matlab / Simulink Block Error

조회 수: 11 (최근 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 CenterFile Exchange에서 General Applications에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by