state space matrix magnitude changes sampling rate
古いコメントを表示
Here's the code, commented through. You don't need to know the physics to help me with this problem (although if you see a mistake I made, please let me know!). Basically, there are two problems: specifying the sample time in the ss call gives me answers I don't understand, and the matrix magnitude affects the sampling rate.
close all
clear
format long
Aoverdx = (0.005145/(2.5*10^-5));
k = 429; %thermal conductivity of silver
kg = 0.1349; % 0.1349 kg silver
specificheatcapacity = 235; %235 J/kg K
mc = kg*specificheatcapacity;
% The equation for current temperature difference is:
% T[t+1] =T_initial + 0*T[t] + Q/mc, where T_initial is x0(1)
% This goes in the first line of the transition matrix A.
% The equation for total heat flow is:
% Q[t+1] = 1*Q[t] + (-kA/dx)*T
% This goes in the second line of the transition matrix A.
A = [0 1/mc;-k*Aoverdx 0];
% A= A/1000;
% ^test what happens when you uncomment this line and line 26
B=[0;0];D=[0]; %not testing for inputs right now
C = [1 0]; %observing T, the temperature difference.
% Try switching to C = [0 1] to see how the change in heat flux
% synchronizes with the temperature changes, displaying undamped
% energy exchange
sys1 = ss(A,B,C,D); %setting sample times gives really weird errors
t = 0:0.001:.12;
% t=t*1000;
u = zeros(size(t)); %no inputs
startingTempDiff = 20; %T_initial ,temp difference = 20 K
x0=[startingTempDiff 0];
[y,t]=lsim(sys1,u,t,x0);
lsim(sys1,u,t,x0)
TimeToMin = t(find(y==min(y))) % notice how this time changes when
% you uncomment lines 17 and 26
% Also notice how if you JUST uncomment line 26, an undersampling
% error appears, but if you reduce the matrix magnitude in line 17,
% that error goes away. Why does magnitude affect sampling rate?
Ultimately, I really need the simulation to show the same TimeToMin no matter what the time vector spacing is; this is a physical process that should take a certain amount of time no matter how quickly you sample it.
Thanks for the help!
Context, if you're interested:
I'm trying to develop a controller for heat flow across a silver medium with a uniform thickness. To do that, I plan to simulate with a state space model that incorporates the physical laws, convert to transfer function, specify rise time and steady state error, and then use root locus optimization to determine the parameters I need for my controller.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で General Applications についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!






