k=input('选择转换方式(1--摄氏转换为华氏,2--华氏转换为摄氏)罩扒:')
if
k~=1
&
k~=2
disp('请指定转换方式')
break
end
tin=input('输入待转变的温度(允许输入数组):')
if
k==1
tout=tin*9/5+32
%
摄氏转换为华氏
k1=2
elseif
k==2
tout=(tin-32)*5/9
%
华知稿氏转换为摄氏
k1=1
end
str=['物猛昌
°C''
°F']
disp(['转换前的温度',
'
',
'转换后的温度'])
disp(['
',num2str(tin),str(k,:),
'
',
num2str(tout),str(k1,:)])再建立一个模拟系统,将摄氏温度转换为华氏温度(Tf
=
9/5Tc+32)。
我做第二个题目function pdemodel
[pde_fig,ax]=pdeinit
pdetool('appl_cb',1)
set(ax,'DataAspectRatio',[1 6.5 1])
set(ax,'PlotBoxAspectRatio',[15 10 1])
set(ax,'XLim',[-15 15])
set(ax,'YLim',[-10 120])
set(ax,'XTickMode','auto')
set(ax,'YTickMode','auto')
% Geometry description:
pderect([0 1 100 0],'R1')
set(findobj(get(pde_fig,'Children'),'Tag','PDEEval'),'String','R1')
% Boundary conditions:
pdetool('changemode',0)
pdesetbd(4,'neu',1,'0','0')
pdesetbd(3,'dir',1,'1','0')
pdesetbd(2,'neu',1,'0','0')
pdesetbd(1,'dir',1,'1','100')
% Mesh generation:
setuprop(pde_fig,'Hgrad',1.3)
setuprop(pde_fig,'refinemethod','regular')
pdetool('initmesh')
pdetool('refine'宽扒)
pdetool('refine')
pdetool('refine')
pdetool('refine')
% PDE coefficients:
pdeseteq(1,'1.0','0.0','0','1.0','0:10','0.0','0.0','[0 100]')
setuprop(pde_fig,'currparam',['1.0''0.0''0 ''1.0'])
% Solve parameters:
setuprop(pde_fig,'solveparam',...
str2mat('0','18432','10','pdeadworst',...
'0.5'慎唯昌,'longest','0','1E-4','','fixed'山唯,'Inf'))
% Plotflags and user data strings:
setuprop(pde_fig,'plotflags',[1 1 1 1 1 1 1 1 0 0 0 1 1 1 0 0 0 1])
setuprop(pde_fig,'colstring','')
setuprop(pde_fig,'arrowstring','')
setuprop(pde_fig,'deformstring','')
setuprop(pde_fig,'heightstring','')
% Solve PDE:
pdetool('solve')
刚好这里段悔有一个现成的%自己编程剔亩昌除数据异常值
clear off
clc
X=[1 3 5 7 4 6 3 8 4 7 12 3 5 7 17 4 6 7 8 5 3]
ls=length(X)
K=3
figure(1)
plot(X)
for i=1:3
A1(i)=abs(X(i)-(X(i+3)+X(i+2)+X(i+1))/3)
Y1=[abs(X(i+3)-X(i+2))abs(X(i+3)-X(i+1))abs(X(i+1)-X(i+2))]
Y(i)=max(Y1')
if(A1(i)/Y(i)>K)
X(i)=(X(i+1)+X(i+2)+X(i+3))/3
else
end
end
for i=ls-2:ls
A2(i)=abs(X(i)-(X(i-1)+X(i-2)+X(i-3))/3)
Z1=[abs(X(i-3)-X(i-2))abs(X(i-3)-X(i-1))abs(X(i-1)-X(i-2))]
Z(i)=max(Z1')
if(A2(i)/Z(i)>K)
X(i)=(X(i-3)+X(i-2)+X(i-1))/3
else
end
end
for i=4:ls-3
A1(i)=abs(X(i)-(X(i-3)+X(i-2)+X(i-1))/3)
A2(i)=abs(X(i)-(X(i+1)+X(i+2)+X(i+3))/3)
Y1=[abs(X(i-3)-X(i-2))abs(X(i-2)-X(i-1))abs(X(i-3)-X(i-2))]
Y(i)=max(Y1')
Z1=[abs(X(i+3)-X(i+2))abs(X(i+3)-X(i+1))abs(X(i+1)-X(i+2))]
Z(i)=max(Z1')
if(A1(i)/Y(i)>K&A2(i)/Z(i)>K)
X(i)=(X(i-3)+X(i-2)+X(i-1)+X(i+1)+X(i+2)+X(i+3))/6
else
end
end
figure(2)
plot(X)
再握耐正来一个简单的
clc
clear all
load X
K=1N=length(X)
x=X
figure(1)
plot(x)
for i=4:N-3
if (x(i)-x(i-1)>K&x(i)-x(i-2)>K&x(i)-x(i-3)>K)
x(i)=(x(i-3)+x(i-2)+x(i-1)+x(i+1)+x(i+2)+x(i+3))/6
end
end
figure(2)
plot(x)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)