negative x axis meaning

조회 수: 5 (최근 30일)
Gavin Seddon
Gavin Seddon 2020년 2월 11일
댓글: John D'Errico 2020년 2월 11일
Hello
I have a vector plot created from multiple functions. The x axis values are incorrect and some are negative. Does matlab assign x axis in order to generate a suitable graph?
GS

채택된 답변

John D'Errico
John D'Errico 2020년 2월 11일
편집: John D'Errico 2020년 2월 11일
This is confusing as a question. You have a plot of some numbers. Some of them are negative. Of course MATLAB will extend the axis out to include the values you plotted. That some of them are negative and you don't want them to be is irrelevant, since MATLAB just plots what you tell it to plot.
If you don't want anything negative, then force it to be so in advance. Or correct what ever bug was there to prevent that from happening.
I suppose, you can always set the axis limits after the fact, effectively ignoring any negative values. But that just closes your eyes to the problem. I would suggest fixing the problem, rather than just pretending it does not exist.
  댓글 수: 2
Gavin Seddon
Gavin Seddon 2020년 2월 11일
My appologies John my original x values are not negative therefore it would be better to ask 'does matlab modify values to suit itself'. I think your answer suggests it does.
GS
John D'Errico
John D'Errico 2020년 2월 11일
NO. My answer did NOT claim that MATLAB changes anything to suit itself. It plots what you tell it to plot. If the numbes are negative, then it plots negative numbers. Perhaps you think the numbers are not negative. It is difficult to guess what you did, because we are not given an example, just a vague question. If you think you can show that MATLAB does something strange, then give an example that shows MATLAB doing something strange. How else can I possibly answer a vague question?
Be careful, by the way. Sometimes you may think your numbers are not negative. However, floating point arithmetic is a tricky thing, since I can cause a negative number to arise even when it may not seem possible.
.3 - .2 - .1
ans =
-2.77555756156289e-17
The result is negative, but look at the number. Then think about how MATLAB stores a number like 0.3. Does it store 0.3? No. It stores the number in binary form, which cannot represent 0.3 exactly.
My guess is you are seeing something like this, a negative value created out of thin air. But that is just understanding floating point numbers. So if you have something concrete, then show what you did, and explain why you are confused. Otherwise I am forced to just make random guesses as to your real meaning.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by