It doesn't count right

조회 수: 1 (최근 30일)
Stanislav Kotzev
Stanislav Kotzev 2018년 1월 11일
편집: John D'Errico 2018년 1월 11일
It count my 0,00xxxxxx number as 0 and doesn't count anything at all, any idea how to solve it ?
  댓글 수: 3
Jan
Jan 2018년 1월 11일
편집: Jan 2018년 1월 11일
Yes.
Please explain at first, what "it" is, what "count" means, the meaning of the bunch of x's, and of course post the relevant part of the code.
Stanislav Kotzev
Stanislav Kotzev 2018년 1월 11일
편집: Guillaume 2018년 1월 11일
I tried but nothing happens, the code is:
alpha=0,0039;
beta=0,022;
H=202;
h=0:1:202;
gama=alpha+beta*i;
Uin=1058,53206;
U=Uin*abs(cosh(gama*(H-h)))/abs(cosh(gama*H));

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

답변 (3개)

Guillaume
Guillaume 2018년 1월 11일
편집: Guillaume 2018년 1월 11일
It is really hard to figure out what the problem is when the statement includes vague words such as it without specifying what it is, or nothing happens when clearly something happens.
Is your problem that you're trying to use , as a decimal mark. As far as I know matlab only supports . as the decimal mark, regardless of your locale settings. Therefore,
alpha = 0.0339;
%and so on

Jan
Jan 2018년 1월 11일
편집: Jan 2018년 1월 11일
alpha=0,0039;
beta=0,022;
Matlab uses the dot as decimal separator. So you have to change this to
alpha = 0.0039;
beta = 0.022;
Your code evaluates:
alpha = 0
and then as next command
0039;
which does nothing, but is not an error also.

John D'Errico
John D'Errico 2018년 1월 11일
편집: John D'Errico 2018년 1월 11일
Hmm. I wonder if you are using MATLAB wrongly. At least, the version of MATLAB that you happen to be using. For example, when I type this in MATLAB:
alpha=0,0039;
alpha =
0
I get alpha is EXACTLY zero. Not 0.00329. As you can see, I'm using a decimal point, not a comma.
So for me, MATLAB sees the comma as a separator between statements here.
But, from your name and your use of numbers like 0,0039, I will guess that your expectation is that MATLAB should see that as a number. MATLAB uses a numeric format chosen to match the expectation. I looked in the preferences for my US version, and I did not see one that would allow me to change that behavior, except in how it would export numbers placed onto the system clipboard.
My guess is you happen to be using a version of MATLAB, perhaps obtained here in the states, that would require you to write those lines as:
alpha=0.0039;
beta=0.022;
Uin=1058.53206;

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by