Why does streamslice not work with single precision data?

7 ビュー (過去 30 日間)
Keith Taylor
Keith Taylor 2014 年 2 月 27 日
コメント済み: Keith Taylor 2014 年 2 月 28 日
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 Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by