在Matlab中使用For循环进行绘图

帕特里克·贝利

我编写了一个代码,使用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] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

for循环中使用ggplot进行绘图不起作用

来自分类Dev

在MATLAB 2014b中使用日语字符进行绘图

来自分类Dev

在Matlab中使用for循环

来自分类Dev

绘图无法在for循环中使用

来自分类Dev

在 for 循环中使用保持更新绘图

来自分类Dev

使用Matlab进行3D绘图

来自分类Dev

使用滑块在Matlab中进行实时绘图

来自分类Dev

使用Matlab进行3D绘图

来自分类Dev

使用滑块在Matlab中进行实时绘图

来自分类Dev

无法在python中使用plotly进行绘图

来自分类Dev

在Pandas / Python中使用GroupBy进行绘图

来自分类Dev

在R中使用Shiny进行绘图

来自分类Dev

防止在MATLAB中使用for循环

来自分类Dev

在Matlab的'for'循环的'to'中使用变量

来自分类Dev

在循环中使用循环进行编号

来自分类Dev

在 matplotlib 中使用 for 循环绘图,并带有列表

来自分类Dev

使用Sweave在for循环中进行多个绘图

来自分类Dev

使用Matlab进行顺序后处理和绘图

来自分类Dev

MATLAB中的ezplot,如何使用函数句柄进行绘图?

来自分类Dev

在Matlab中从while循环绘图

来自分类Dev

在matlab中使用一个字符进行循环

来自分类Dev

如何在Matlab中使用日期时间数组进行for-if循环?

来自分类Dev

用numpy分隔数组以在python中使用matplotlib进行绘图

来自分类Dev

在HTML 5中使用画布进行绘图

来自分类Dev

在熊猫中使用比例不同的列进行绘图

来自分类Dev

在ggplot中使用facet_grid进行绘图

来自分类Dev

用numpy分隔数组以在python中使用matplotlib进行绘图

来自分类Dev

如何在r中使用因子变量进行绘图

来自分类Dev

从数据集进行循环绘图