Curl function outputting -inf and NaN

조회 수: 2 (최근 30일)
Spencer
Spencer 2011년 6월 8일
댓글: Robert 2023년 11월 16일
Hello All,
I have a 2-D velocity field I am trying to calculate the curl of. My input
curlX=curl(Y,Z,V,W);
and it gives me a matrix of a bunch of -inf, inf and NaN.
if I input just curlX=curl(V,W) then it gives me a result for curl but not on the correct coordinate system. Can someone please help me with this?
-Spencer
  댓글 수: 1
Robert
Robert 2023년 11월 16일
Try curlX=curl(Y.',Z.',V.',W.');

댓글을 달려면 로그인하십시오.

채택된 답변

Andrew Newell
Andrew Newell 2011년 6월 8일
If quiver works but not curl, your coordinates may not have the correct form. They have to be monotonic, as if set up by meshgrid.
  댓글 수: 1
Spencer
Spencer 2011년 6월 8일
Thank you andrew. After you said this I went back and made a meshgrid instead of using the given grid and it now works fine. Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

Sean de Wolski
Sean de Wolski 2011년 6월 8일
Apparently you're dividing a positive number by zero (inf), a negative number by zero (-inf) and zero by zero (nan). What does your data look like?

Spencer
Spencer 2011년 6월 8일
My data consists of 4 40*40 matrices, each matrix representing the Y, Z, V, or W coordinates and velocities respectively.. I dont know exactly what the curl function in matlab does, so I may need to look into it.
Another note: when I use quiver(YY,ZZ,VV,WW) it outputs my velocity field as it should be. So it seems like my matrices are OK.
  댓글 수: 1
Andrew Newell
Andrew Newell 2011년 6월 8일
Extra details for your question should be included as comments (like this one) or edits to your original question.

댓글을 달려면 로그인하십시오.


Spencer
Spencer 2011년 6월 8일
some of my data is very small velocities i.e. e^-4, could this be the reason I am getting these small numbers, is the program carrying the small decimal places?
  댓글 수: 1
Sean de Wolski
Sean de Wolski 2011년 6월 8일
MATLAB works in double precision so it shouldn't have issues at 1e4. Unless you're dividing a very large number by 1e4.
Even:
2e200/1e4
doesn't go to inf.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by