| 查看: 1408 | 回复: 3 | ||
shan_yin木虫 (正式写手)
|
[求助]
请教各位大侠,matlab GPU编程时,如何在arrayfun函数中进行数据存储? 已有1人参与
|
|
示例如下。我需要把arrayfun函数中每次计算的z的值保存到Pos矩阵中,并在循环结束后对矩阵进行操作。请各位大侠赐教! function test_GPU_computing maxIterations=500; gridSize=1500; xlim=[-0.75, -0.73]; ylim=[ 0.12, 0.14]; t=tic(); x=gpuArray.linspace( xlim(1), xlim(2), gridSize ); y = gpuArray.linspace( ylim(1), ylim(2), gridSize ); [xGrid,yGrid] = meshgrid( x, y ); count=arrayfun( @tar_fun,xGrid, yGrid, maxIterations ); count=gather(count); % Fetch the data back from the GPU gpuArrayfunTime=toc(t) figure(1) imagesc(x,y,count) reset(gpuDevice(1)) function count=tar_fun(x0,y0,maxIterations) z0=complex(x0,y0); z=z0; count=1; %Pos=[]; while (count <= maxIterations) && (abs(z) <= 2) count=count+1; z=z*z+z0; %Pos(count,1)=z; end count=log(count); |
» 猜你喜欢
实验室接单子
已经有4人回复
全日制(定向)博士
已经有4人回复
假如你的研究生提出不合理要求
已经有6人回复
对氯苯硼酸纯化
已经有3人回复
求助:我三月中下旬出站,青基依托单位怎么办?
已经有12人回复
不自信的我
已经有12人回复
所感
已经有4人回复
论文终于录用啦!满足毕业条件了
已经有28人回复
要不要辞职读博?
已经有7人回复
北核录用
已经有3人回复
shan_yin
木虫 (正式写手)
- 应助: 1 (幼儿园)
- 金币: 1833.7
- 散金: 170
- 红花: 5
- 帖子: 590
- 在线: 169.7小时
- 虫号: 4856693
- 注册: 2016-07-20
- 性别: GG
- 专业: 动力学与控制
2楼2018-12-15 16:02:58
chendequan
铁虫 (小有名气)
★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ...
感谢参与,应助指数 +1
shan_yin: 金币+200 2018-12-15 20:58:52
emuch: 屏蔽内容, 违规存档, 违规发布联系方式 2018-12-17 10:30:19
感谢参与,应助指数 +1
shan_yin: 金币+200 2018-12-15 20:58:52
emuch: 屏蔽内容, 违规存档, 违规发布联系方式 2018-12-17 10:30:19
|
本帖内容被屏蔽 |
3楼2018-12-15 20:41:05
shan_yin
木虫 (正式写手)
- 应助: 1 (幼儿园)
- 金币: 1833.7
- 散金: 170
- 红花: 5
- 帖子: 590
- 在线: 169.7小时
- 虫号: 4856693
- 注册: 2016-07-20
- 性别: GG
- 专业: 动力学与控制
4楼2018-12-15 21:03:38












回复此楼