我编写了一个代码,使用for循环确定ti和t的值。当我绘制变量时,我得到的所有点都是散点图,我想绘制一条最合适的线作为线性数据。但是,正在绘制数据,因为每个点都是他们自己的数据集。有没有一种方法可以将数据收集到矩阵中以绘制线性图
clc
全部清除全部关闭
%Heat Transfer
% I is the current passing through the conductor
I=475;
% h is the coeffcient of convective heat [W/ m^2*K] transfer
h=10;
% D is the diameter of the conductor [m]
D=0.02364;
% o is the stefan-boltzman constant [W/m^2*K^4]
o= 5.67*(10^-8);
% e is the emissivity coeffcient of the conductor
e= 0.2;
% u is the absorbivity coeffcient of the conductor
u= 0.5;
% G is the solar irradiance
G= 1200;
% r is the resistivity of the conductor per metre
r= 0.0000864;
%Qs is the Solar irradiation into the conductor
%Qs=u*D*G;
%Qg is the columbic losses generated internally
%Qg=i^2*r;
% Qc is the convective energy flowing out of the conductor
%Qc=h*pi*D*(t-ti);
% Qr is the radiative energy out of the conductor
% Qr=o*e*D*(t^4 - ti^4);
% ti is the ambient temperature [K]
% t is the temperature of the conductor [K]
for ti= 213:1:313
a= @(t) (h*pi*D*(t-ti))+(o*e*D*pi*(t^4 - ti^4))-((u*D*G)+(I^2*r));
t= fzero(a,0);
%fprintf('The temperature of the conductor is: %.2f K when the outside temperature is %g K \n',t,ti)
hold on
end
%I want to plot (ti,t)
将您的for循环中的数据输出收集到单个数组中,然后使用该调用一次plot。可以在您的for循环中插入以下内容:
timevect = 213:313;
yvect(1, length(timevect)) = 0;
for ii = 1:length(timevect)
ti = timevect(ii);
a= @(t) (h*pi*D*(t-ti))+(o*e*D*pi*(t^4 - ti^4))-((u*D*G)+(I^2*r));
t = fzero(a,0);
yvect(ii) = t;
end
plot(timevect, yvect)
注意,现在图中坐标轴的时间数据在矢量中,ydata也在矢量中。您在for循环中绘制标量。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句