作业帮 > 综合 > 作业

MATLAB运行时出现All rows in the bracketed expression must have th

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/10/04 22:14:03
MATLAB运行时出现All rows in the bracketed expression must have the same number of columns.
函数文件
%函数定义文件function dy =lgkt(t,y,Ta,Va);
global g;g=9.8;
m=0.78;G=5.6*10^-6
%相关变量定义nu=4.1618*(10^-9)*((Ta^(5/2))/(Ta+114)) % 空气运动粘性系数
lambda=2.0848*(10^-3)*((Ta^(3/2))/(Ta+114))
p=1/(1.145+0.000903*(y(1)-273)) %流体密度
V=4*G/(pi*p*(y(2)^2))
Cf=0.78*((y(2)*abs(V-Va))/nu)^-0.61 %气流拉伸力系数
h=0.42*lambda*(nu^-0.334)*((abs(V-Va))^0.334)*y(2)^-0.666 %传热系数
aita=0.0011264*exp(6021.44/y(1)) %剪切粘度
Cpf=0.3669+0.00242*(y(1)-273) %聚合物定压比热
% 流体力学微分方程组
dy=[(pi*y(2)*h*(y(1)-Ta))/(G*Cpf);
(-0.5*(pi/4)^(1-1/m))*(p/G)*((y(3)/(3*aita))^(1/m))*y(2)^(3-2/m);
0.5*pi*y(2)*Cf*1.225*(Va-V)^2 -(2*V*G/y(2))*((-0.5*(pi/4)^(1-1/m))*(p/G)*((y(1)/(3*aita))^(1/m))*y(2)^(3-2/m)) -(pi/4)*(y(3)^2)*p*g]
主程序如下
clc
clear all
format long
Va=[9.0000 ;10.8880;10.7056;25.7603;55.9674] %气体速度值
Ta=[577.5280;577.5100;577.5630;577.7520;577.9760] %气体温度值
y0=[583 525*10^-6 3.61*10^-4]; %流变力、聚合物温度、喷嘴出口直径初始值
options=odeset('RelTol',1e-7); %计算精度参数设置
tspan=0:4;
yy=y0;
for i=1:length(tspan)-1
[z,y]=ode45(@lgkt,[tspan(i),tspan(i+1)],y0,options,Ta(i),Va(i));
y0=y(end,:);
yy=[yy,y0];
end
plot(tspan,yy,'-o')
yy
运行后出现
Error using ==> vertcat
All rows in the bracketed expression must have the same
number of columns.
Error in ==> lgkt at 26dy=[(pi*y(2)*h*(y(1)-Ta))/(G*Cpf);
请大神帮忙看看错在什么地方,找了好久都没搞定
我把微分方程后面的式子用xx代替,就不出现那个错了
估计是你的式子太长了.
%函数定义文件
function dy =lgkt(t,y,Ta,Va);
global g;
g=9.8;
m=0.78;
G=5.6*10^-6
%相关变量定义
nu=4.1618*(10^-9)*((Ta^(5/2))/(Ta+114)) % 空气运动粘性系数
lambda=2.0848*(10^-3)*((Ta^(3/2))/(Ta+114))
p=1/(1.145+0.000903*(y(1)-273)) %流体密度
V=4*G/(pi*p*(y(2)^2)) %流体速度
Cf=0.78*((y(2)*abs(V-Va))/nu)^-0.61 %气流拉伸力系数
h=0.42*lambda*(nu^-0.334)*((abs(V-Va))^0.334)*y(2)^-0.666 %传热系数
aita=0.0011264*exp(6021.44/y(1)) %剪切粘度
Cpf=0.3669+0.00242*(y(1)-273) %聚合物定压比热
% 流体力学微分方程组
%下面有改动
xx=(2*V*G/y(2))*((-0.5*(pi/4)^(1-1/m))*(p/G)*((y(1)/(3*aita))^(1/m))*y(2)^(3-2/m))-(pi/4)*(y(3)^2)*p*g
dy=[(pi*y(2)*h*(y(1)-Ta))/(G*Cpf); ...
(-0.5*(pi/4)^(1-1/m))*(p/G)*((y(3)/(3*aita))^(1/m))*y(2)^(3-2/m); ...
0.5*pi*y(2)*Cf*1.225*(Va-V)^2-xx]
再问: 首先谢谢你看了我的问题并给与回答,非常感谢,我用了你的方法试了一下,结果还是出现那种问题,请问你那边运行没出现错误吗?希望大侠能够告知,多谢啦
再答: 也抱错,但不是你那个错误了 dy = 1.0e+019 * 0.00000000002894 + 0.00000000004348i -0.00081313512345 - 0.00275330942908i 6.46008223834274 - 0.00000002825524i Warning: Failure at t=3.000000e+000. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (7.105427e-015) at time t. > In ode45 at 355 In Untitled3 at 12 ??? Error using ==> plot Vectors must be the same lengths. Error in ==> Untitled3 at 16 plot(tspan,yy,'-o')
再问: 怪事了,太谢谢你了,我晚上回去捣鼓捣鼓,呵呵被这个错误折腾好久了