Why does streamslice not work with single precision data?

7 次查看(过去 30 天)
I was having issue plotting streamlines using stream slice, and I tracked it down to the fact that the X,Y,U,V data I was using was single precision. I modified it from double precision because the source of the data is the result of post processing data, and I wanted to conserve space. (Talking potentially TB of data). But, now all my data crunching appears useless if I want to plot streamlines, since I can't seem to use Single precision data.
I either would like to know how to use streamslice with single precision data, or know how to save structures of data from matlab to a file and truncate the numbers in the arrays being saved. I dont need double precision to represent 1.35 in an array.

回答(1 个)

per isakson
per isakson 2014-2-27
编辑:per isakson 2014-2-27
It looks like a bug to me (R2013a).
An example from the documentation works fine with double, but produces nothing but the default empty axes with single. There is no error message or warning.
load wind
figure
streamslice(x,y,z,u,v,w,[],[],[5])
axis tight
figure
streamslice(single(x),single(y),single(z),single(u) ...
,single(v),single(w),single([]),single([]),single([5]))
axis tight
.
Workaround
figure
streamslice(double(x),double(y),double(z),double(u) ...
,double(v),double(w),double([]),double([]),double([5]))
axis tight
- or make a wrapper. Not tested
function streamslice4single( X,Y,Z,U,V,W,startx,starty,startz )
x = double(X);
y = double(Y);
z = double(Z);
u = double(U);
v = double(V);
w = double(W);
sx = double( startx );
sy = double( starty );
sz = double( startz );
streamslice(x,y,z,u,v,w,sx,sy,sy)
end
  1 个评论
Keith Taylor
Keith Taylor 2014-2-28
Thank you for the response. It came to me about a minute before I saw this reply. This work around does work.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Volume Visualization 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by