필터 지우기
필터 지우기

How to plot f(x) =|x| in matlab

조회 수: 2 (최근 30일)
Neo
Neo 2017년 2월 6일
편집: Stephen23 2017년 2월 6일
Hi I am trying to make this plot which requires this graph, learning matlab more and more, can someone help me to learn this?
Thanks!
Neo
  댓글 수: 1
Stephen23
Stephen23 2017년 2월 6일
편집: Stephen23 2017년 2월 6일
@Neo: you might like to read this:
MATLAB has comprehensive, readable documentation. Learn how to browse it, how the links work, how it is arranged by topic. And then use the documentation every time you are writing some code: how does it work, what inputs does it need, what edge cases to be aware of ?

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

답변 (1개)

Adam
Adam 2017년 2월 6일
편집: Adam 2017년 2월 6일
doc abs
doc plot
The rest is trivial. I assume you know how to create a variable. You just need to create one for x and one for absX and then plot them against each other.
I'm sure someone will come along and obligingly post a fully working answer, but if you want to learn then taking tips and working it out for yourself works better generally.
  댓글 수: 2
Neo
Neo 2017년 2월 6일
Thank you! So like this: f = abs(x); then I think I add x = linspace(-1,1); because it coordinates the axis? But not sure why its called linspace and what the ranges are (I think up to 100?) Thank you!
Adam
Adam 2017년 2월 6일
Yes, that should do the job.
doc linspace
!!
Will tell you the answers to these things. Matlab has the best documentation of any software I have used and far better than other programming languages. Make full use of it.
I can't remember off-hand how many values default linspace gives you, probably 100, but I always use the 3rd argument to specify how many I want anyway.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by