Varying input into a transfer function in simulink
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to vary a constant inside a transfer function in simulink. For example the transfer function could be: 1/(AS+1) where A is the varying constant. Then I want it to store the ouptut of each value in an array.
I tried doing this in Matlab with the following code:
G = zeros(10,2);
for i = 1:1:10
A = i;
out = sim('');
values1 = out.simout.values(:,1);
values2 = out.simout.values(:,2);
G = values2.*values1;
end
However, this code does not store every value of G that is calculated, and does not allow for A to be non integer values like i = 1:0.01:10.
Is there any way to do this?
0 Kommentare
Akzeptierte Antwort
Paul
am 11 Jan. 2023
Hi Jake,
It looks like you're tring to vary the value of A between runs, not during a run.
In this case, I think you want something like this:
Avals = 1:.01:10;
G = cell(numel(Avals),1);
for i = 1:numel(Avals)
A = Avals(i);
out = sim('');
values1 = out.simout.values(:,1);
values2 = out.simout.values(:,2);
G{i} = values2.*values1; % use a cell array here if values can have a different number of rows from one run to the next
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!