找回密码
 注册
Simdroid-非首页
查看: 300|回复: 12

[建模专区] 怎么保存数据??急求高手

[复制链接]
发表于 2009-5-27 10:46:08 | 显示全部楼层 |阅读模式 来自 安徽合肥
new
gen id 1 1000 rad 0.1 0.1 x 0 8 y 0.2 12
prop dens 1000 kn 1e6 ks 1e6
set grav 0 -9.81

define fillarr
array pos(1000,2)
loop j (1,1000)
  xpos=b_x(find_ball(j))
  ypos=b_y(find_ball(j))
  pos(j,1)=xpos
  pos(j,2)=ypos
endloop
end
fillarr
上面是把ball的位置写到一个数组里面了
怎么把这个数组保存成数据文件如txt格式的assii文件
 楼主| 发表于 2009-5-27 22:16:52 | 显示全部楼层 来自 合肥工业大学
Simdroid开发平台
1# wqsoooooooooo

我自己把它解决了

呵呵呵呵
下面写出来分享一下啊
回复 不支持

使用道具 举报

 楼主| 发表于 2009-5-27 22:19:25 | 显示全部楼层 来自 合肥工业大学
不能上传附件???????
只贴出程序来了

new
gen id 1 1000 rad 0.1 0.1 x 0 8 y 0.2 12
prop dens 1000 kn 1e6 ks 1e6
set grav 0 -9.81


define fillarr
        array pos(1000,2)
        loop j (1,1000)
                xpos=b_x(find_ball(j))
                ypos=b_y(find_ball(j))
                pos(j,1)=xpos
                pos(j,2)=ypos
        endloop
end
fillarr

define WriteToFile
        array line(1000)
        loop n (1,1000)
                midd='   '
                msg=string(pos(n,1))+midd+string(pos(n,2))
                line(n)=msg
        endloop
        status=open('pos.txt',1,1)
        status=write(line,1000)
        status=close
end

WriteToFile


运行后就可以在目标目录下找到pos.txt了

呵呵额呵呵呵呵
回复 不支持

使用道具 举报

发表于 2009-5-28 21:30:32 | 显示全部楼层 来自 台湾
new
gen id 1 1000 rad 0.1 0.1 x 0 8 y 0.2 12
prop dens 1000 kn 1e6 ks 1e6
set grav 0 -9.81
define fillarr
array pos(1000,2)
loop j (1,1000)
xpos=b_x(find_ball(j))
ypos=b_y(find_ball(j))
pos(j,1)=xpos
pos(j,2)=ypos
endloop
end
set hist_rep 5000

def setid
        loop n (1,5)
        aa = 2*n-1
        bb =2*n
;        hist id aa ball xp id n
;        hist id bb ball yp id n
        endloop
end

hist id 1 ball xp id 1
hist id 2 ball yp id 1


setid

print aa

cycle 5000

hist write 1 2 file GG.HIS

sa savefile

===========================================

我是用HIST保存數據的!!

後面define writetofile 我做修改過!
回复 不支持

使用道具 举报

发表于 2009-5-30 00:07:45 | 显示全部楼层 来自 美国
great job!
回复 不支持

使用道具 举报

发表于 2009-7-25 22:58:05 | 显示全部楼层 来自 湖北武汉
不错 学习了
回复 不支持

使用道具 举报

发表于 2009-8-18 17:56:11 | 显示全部楼层 来自 北京
不错学习了
回复 不支持

使用道具 举报

发表于 2010-4-14 21:11:42 | 显示全部楼层 来自 英国
正好用上,太好了.谢谢LZ
回复 不支持

使用道具 举报

发表于 2010-6-11 21:28:39 | 显示全部楼层 来自 湖南长沙
目前还看不懂
回复 不支持

使用道具 举报

发表于 2010-6-23 10:25:29 | 显示全部楼层 来自 北京
不错啊,学习了
回复 不支持

使用道具 举报

发表于 2010-11-15 16:49:03 | 显示全部楼层 来自 江苏南京
呵呵,写成ascii用处不大啊
回复 不支持

使用道具 举报

发表于 2011-5-3 20:25:13 | 显示全部楼层 来自 武汉大学
不错不错 谢谢
回复 不支持

使用道具 举报

发表于 2011-5-10 17:00:51 | 显示全部楼层 来自 中国
初学者,看不懂,
回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Simapps系列直播

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-9-29 19:15 , Processed in 0.059356 second(s), 14 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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