stream2 fails if coordinates are single precision?

조회 수: 3 (최근 30일)
Chad Greene
Chad Greene 2022년 8월 25일
답변: Javed Mohd 2023년 1월 19일
I've encountered a strange behavior with stream2 which fails silently if any input coordinates are single precision. It looks like the velocity data can be single precision, but the grid coordinates and the query coordinates must both be double precision.
Here's an MWE:
x = 1:100;
y = 1:100;
vx = rand(100);
vy = rand(100);
% This works:
st = cell2mat(stream2(x,y,vx,vy,50,50));
% This works:
st = cell2mat(stream2(x,y,single(vx),single(vy),50,50));
% This fails (empty output):
st = cell2mat(stream2(single(x),single(y),vx,vy,50,50));
% This fails:
st = cell2mat(stream2(x,y,vx,vy,single(50),single(50)));
% This fails:
st = cell2mat(stream2(single(x),single(y),single(vx),single(vy),50,50));
% This fails:
st = cell2mat(stream2(single(x),single(y),single(vx),single(vy),single(50),single(50)));
Is there something I'm missing? Is there a way to use stream2 with single-precision coordinates? Shouldn't the function throw an error if inputs are single, instead of producing an empty output?

답변 (1개)

Javed Mohd
Javed Mohd 2023년 1월 19일
I also faced the same problem but thanks to your querry, I am able to rectify by casting my grid coordinates into double.

카테고리

Help CenterFile Exchange에서 Just for fun에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by