爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 6528|回复: 5

[讨论] matlab数组计算异常

[复制链接]

新浪微博达人勋

发表于 2013-1-30 10:13:53 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
clc
data1=load('g:\03013\hebei\richarson\0917.txt');
data2=load('g:\03013\hebei\richarson\0921.txt');
data3=load('g:\03013\hebei\richarson\1014.txt');
data4=load('g:\03013\hebei\richarson\1103.txt');
u11=data1(:,1);
u12=data1(:,2);
t13=data1(:,3);
t14=data1(:,4);
u21=data2(:,1);
u22=data2(:,2);
t23=data2(:,3);
t24=data2(:,4);
u31=data3(:,1);
u32=data3(:,2);
t33=data3(:,3);
t34=data3(:,4);
u41=data4(:,1);
u42=data4(:,2);
t43=data4(:,3);
t44=data4(:,4);
for i=1:1440
    if u11(i)==99999.0
        u11(i)=NaN;
    end
    if u12(i)==99999.0
        u12(i)=NaN;
    end
    if t13(i)==99999.0
        t13(i)=NaN;
    end
    if t14(i)==99999.0
        t14(i)=NaN;
    end
    if u21(i)==99999.0
        u21(i)=NaN;
    end
    if u22(i)==99999.0
        u22(i)=NaN;
    end
    if t23(i)==99999.0
        t23(i)=NaN;
    end
    if t24(i)==99999.0
        t24(i)=NaN;
    end
    if u31(i)==99999.0
        u31(i)=NaN;
    end
    if u32(i)==99999.0
    u32(i)=NaN;
    end
    if t33(i)==99999.0
        t33(i)=NaN;
    end
    if t34(i)==99999.0
        t34(i)=NaN;
    end
    if u41(i)==99999.0
    u41(i)=NaN;
    end
    if u42(i)==99999.0
        u42(i)=NaN;
    end
    if t43(i)==99999.0
        t43(i)=NaN;
    end
    if t44(i)==99999.0
        t44(i)=NaN;
    end
end     
r1=(9.8./(t13+273.15)).*(0.0065+(t14-t13)/60)./((u12-u11)/60).^2;
r2=(9.8./(t23+273.15)).*(0.0065+(t24-t23)/60)./((u22-u21)/60).^2;
r3=(9.8./(t33+273.15)).*(0.0065+(t34-t33)/60)./((u32-u31)/60).^2;
r4=(9.8./(t43+273.15)).*(0.0065+(t44-t43)/60)./((u42-u41)/60).^2;
u111=reshape(u11,10,144);
u112=reshape(u12,10,144);
t113=reshape(t13,10,144);
t114=reshape(t14,10,144);
u221=reshape(u21,10,144);
u222=reshape(u22,10,144);
t223=reshape(t23,10,144);
t224=reshape(t24,10,144);
u331=reshape(u31,10,144);
u332=reshape(u32,10,144);
t333=reshape(t33,10,144);
t334=reshape(t34,10,144);
u441=reshape(u41,10,144);
u442=reshape(u42,10,144);
t443=reshape(t43,10,144);
t444=reshape(t44,10,144);
a11=mean(u111,1);
a12=mean(u112,1);
a13=mean(t113,1);
a14=mean(t114,1);
b11=mean(u221,1);
b12=mean(u222,1);
b13=mean(t223,1);
b14=mean(t224,1);
c11=mean(u331,1);
c12=mean(u332,1);
c13=mean(t333,1);
c14=mean(t334,1);
d11=mean(u441,1);
d12=mean(u442,1);
d13=mean(t443,1);
d14=mean(t444,1);
r11=((9.8./(a13+273.15)).*(0.0065+(a14-a13)/60)./((a12-a11)/60).^2)';
r12=((9.8./(b13+273.15)).*(0.0065+(b14-b13)/60)./((b12-b11)/60).^2)';
r13=((9.8./(c13+273.15)).*(0.0065+(c14-c13)/60)./((c12-c11)/60).^2)';
r14=((9.8./(d13+273.15)).*(0.0065+(d14-d13)/60)./((d12-d11)/60).^2)';
e11=mean(reshape(a11',6,24),1);
e12=mean(reshape(a12',6,24),1);
e13=mean(reshape(a13',6,24),1);
e14=mean(reshape(a14',6,24),1);
f11=mean(reshape(b11',6,24),1);
f12=mean(reshape(b12',6,24),1);
f13=mean(reshape(b13',6,24),1);
f14=mean(reshape(b14',6,24),1);
g11=mean(reshape(c11',6,24),1);
g12=mean(reshape(c12',6,24),1);
g13=mean(reshape(c13',6,24),1);
g14=mean(reshape(c14',6,24),1);
h11=mean(reshape(d11',6,24),1);
h12=mean(reshape(d12',6,24),1);
h13=mean(reshape(d13',6,24),1);
h14=mean(reshape(d14',6,24),1);
rx=((9.8./(e13+273.15)).*(0.0065+(e14-a13)/60)./((e12-e11)/60).^2)';
ry=((9.8./(f13+273.15)).*(0.0065+(f14-f13)/60)./((f12-f11)/60).^2)';
rz=((9.8./(g13+273.15)).*(0.0065+(g14-g13)/60)./((g12-g11)/60).^2)';
rp=((9.8./(h13+273.15)).*(0.0065+(h14-h13)/60)./((h12-h11)/60).^2)';

r1 r11 都可以,到了rx 就不行了~!为啥
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2013-1-30 10:37:16 | 显示全部楼层
报了什么错?最好发上来……建议你下次弄重复性工作的时候编一个函数,用一组数据测试以后用,调用起来方便也不容易出现写错的问题……
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2013-1-30 11:14:43 | 显示全部楼层

??? Error using ==> minus
Matrix dimensions must agree.

Error in ==> ri at 128
rx=((9.8./(e13+273.15)).*(0.0065+(e14-a13)/60)./((e12-e11)/60).^2)';

>>
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2013-1-30 11:25:42 | 显示全部楼层
它说你在做减法的时候出问题了,两个矩阵维数不统一,应该是(e14-a13)写错了,估计是e13吧……
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2013-1-30 14:31:30 | 显示全部楼层
斥鷃 发表于 2013-1-30 11:25
它说你在做减法的时候出问题了,两个矩阵维数不统一,应该是(e14-a13)写错了,估计是e13吧……

........好的! 给力啊 ~ 笔误。。。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2013-3-25 20:21:16 | 显示全部楼层
学习
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表