필터 지우기
필터 지우기

always having zero results

조회 수: 1 (최근 30일)
sukaina abbas
sukaina abbas 2016년 6월 2일
댓글: sukaina abbas 2016년 6월 2일
Hi,
I have a problem with my code.It just two equations to find unknown two values(Y,X). From the first equation, i get Y then, when I put Y in X equation, always having a value of X which is Zero. the x2 in the equation of X is 0.001.
X=0.25*((r1.^2-r2.^2-y1.^2+2*y1* *Y*)/ *x2*);
Y has an integer value and when i put its value such as 7, i get X=-1. But when i Put Y as a letter Y, i get X=0

답변 (1개)

John D'Errico
John D'Errico 2016년 6월 2일
편집: John D'Errico 2016년 6월 2일
Well we cannot do anything with that equation, since it is not valid syntax. There are some spare * characters near the end. I'm not sure if that was a typo, if you did it intentionally, or what.
My guess however, is that Y is not just an integer, but it is probably an integer of form like int8, int16, etc. For example:
z = 0.001 + uint8(2)
z =
2
whos z
Name Size Bytes Class Attributes
z 1x1 1 uint8
So the result is not 2.001, but exactly 2, since the result will be uint8.
Had that integer been in double precision form, the issue would not arise.
  댓글 수: 2
Walter Roberson
Walter Roberson 2016년 6월 2일
I think in the original the user was possibly trying to bold some of the variables
sukaina abbas
sukaina abbas 2016년 6월 2일
Yes I bold Y and x2 any the problem is being solved by just separate the equation in two parts. Many thanks for your cooperation and help

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

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by