24小时热门版块排行榜    

CyRhmU.jpeg
查看: 190  |  回复: 2
当前主题已经存档。

monitor2885

至尊木虫 (职业作家)

队长

[交流] 【求助】如何调出整数值呢

i=0:0.3:10;
a=i.*2+3;
for j=0:10
t=find(floor(i)==j,1);
end
a(t)

i 是从0到10的数列,非整数居多。现在我要找刚刚大于1,2,3,4,5,6,7,8,9,10的i的Index,然后把a(index)输出,请问怎么改程序?就是相当于把下面的index记录储存到一起。

        i   
         0     %index
    0.3000
    0.6000
    0.9000
    1.2000 %index
    1.5000
    1.8000
    2.1000 %index
    2.4000
    2.7000
    3.0000 %index
    3.3000
    3.6000
    3.9000
    4.2000 %index
    4.5000
    4.8000
    5.1000 %index
    5.4000
    5.7000
    6.0000 %index
    6.3000
    6.6000
    6.9000
    7.2000 %index
    7.5000
    7.8000
    8.1000 %index
    8.4000
    8.7000
    9.0000 %index
    9.3000
    9.6000
    9.9000

[ Last edited by monitor2885 on 2009-12-11 at 14:03 ]
回复此楼
Retirement
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dota

木虫 (著名写手)

★ ★
nono2009(金币+1,VIP+0):谢谢应助! 12-11 09:21
monitor2885(金币+1,VIP+0): 12-12 12:23
for j=1:length(i)
if(floor(a(j)) == ceil(a(j)))
    a(j)      % It will print a(j) value on-sreen if it is an integer.
end
end
2楼2009-12-11 03:47:06
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

change0618

铁杆木虫 (著名写手)

方丈大师

★ ★ ★ ★ ★
nono2009(金币+1,VIP+0):谢谢应助! 12-12 11:22
monitor2885(金币+4,VIP+0): 12-12 12:23
i=0:0.3:10;
a=i.*2+3;
tt=[];
for j=0:10
    t=find(i-j>=0 & i-j<0.25);
    tt=[tt;t];
end
a(tt)
3楼2009-12-12 11:01:35
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 monitor2885 的主题更新
普通表情 高级回复(可上传附件)
信息提示
请填处理意见