Why this is plotting blank window?
이전 댓글 표시
P=16;
a=5.51*(10^-10);
h=6.62*(10^-34)
m=9.11*(10*-31)
E=0:0.001:100;
h=6.62*(10^-34);
A=sqrt(2*m*E)/h;
f=(16*(sin(A*a)./(A*a)))+cos(A*a);
plot(abs(A),abs(f),'.b')
댓글 수: 4
John D'Errico
2017년 12월 4일
Please don't paste code as a picture. Instead, learn to use the "{} Code" button.
1. Paste in the code.
2. Select it with the mouse.
3. Click on "{} Code".
Image Analyst
2017년 12월 4일
Actually, your code does not plot anything at all. There is no call to any function which would create any kind of graph/plot/chart. It should not even plot/create a blank white rectangle. Please attach your actual code that you used.
SHEREEN AHMED
2017년 12월 4일
편집: SHEREEN AHMED
2017년 12월 4일
John D'Errico
2017년 12월 4일
편집: John D'Errico
2017년 12월 4일
Sorry. I mistakenly zapped the plot line away when I made the code readable.
답변 (2개)
John D'Errico
2017년 12월 4일
What is f as you generated it?
f
f =
Columns 1 through 28
NaN Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf
Columns 29 through 56
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf
Columns 57 through 84
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf
...
Look carefully at the variables you created. Do they make sense? Does A make sense? Only you know what you are trying to do here.
댓글 수: 4
SHEREEN AHMED
2017년 12월 4일
John D'Errico
2017년 12월 4일
But we don't know if what you did makes any sense. For example, if I look at a few lines of yours:
P=16;
a=5.51*(10^-10);
h=6.62*(10^-34)
m=9.11*(10*-31)
Is m correct? I wonder if that is a typo on your part. Did you really want this?
m=9.11*(10*-31)
m =
-2824.1
Or, this?
m = 9.11e-31
m =
9.11e-31
I'd suggest that you get used to writing these numbers in scientific notation, thus I assume you wanted:
a=5.51e-10;
h=6.62e-34;
m=9.11e-31;
Less chance of a mistake when you write it that way.
As you had it, m is a negative number, and then you take a square root, to form A.
SHEREEN AHMED
2017년 12월 4일
편집: SHEREEN AHMED
2017년 12월 4일
SHEREEN AHMED
2017년 12월 4일
Guillaume
2017년 12월 4일
As indicated by John, your f is full of infinite or nan value, so you have to go back through your expressions and work out why.
Had you done that you would have seen straight away that your A is full of complex values. Since A is the square root of something, that something must be negative to result in complex values.
So let's look at the values of E and m that go into that something
>>m
m =
-2.824100000000000e+03
Well, there you go. m is negative. I'll let you work out why (hint: it's a typo).
That would have taken you the whole of 2 minutes to work out for yourself if you'd simply looked at the values of each of your variables. Instead you had to wait over two hours for somebody else to do it for you.
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!