function is called that will plot a mathematical function in one variable and in range 0 to 10 and function should recive input vector of integer and it has n length even. for example func([100,1500,3000]) will plot that number of points

댓글 수: 4

Walter Roberson
Walter Roberson 2019년 11월 25일
it has n length even
I do not understand that part?
Roger Nadal
Roger Nadal 2019년 11월 25일
length should be even
Walter Roberson
Walter Roberson 2019년 11월 25일
In your example, should it produce three plots, one with 100 points, one with 1500, one with 3000? If so then should they all be on the same plot or should subplots be used?
Roger Nadal
Roger Nadal 2019년 11월 25일
편집: Roger Nadal 2019년 11월 25일
Three different plots and has to give input mathematical expression for example sin(x)+x

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

답변 (2개)

Nicolas Douillet
Nicolas Douillet 2019년 11월 25일

0 개 추천

Perhaps you should have a look at linspace.
u = linspace(1500,3000,16); % since there are 16 values between 1500 and 3000 with a sampling step of 100
figure;
plot(u);
I am not sure this is what you want to do, since your question is not so clear to me.
Hope this could help you anyway.
Best,
N
Walter Roberson
Walter Roberson 2019년 11월 25일

0 개 추천

funstr = input('Enter expression in variable x ', 's');
fun = str2func(vectorize(funstr));
x = linspace(0,1,NumberOfPoints);
y = fun(x);
plot(x, y);
Now generalize this slightly to support multiple plots.

댓글 수: 3

Roger Nadal
Roger Nadal 2019년 11월 26일
편집: Roger Nadal 2019년 11월 26일
It shows error on linspace and Numberof points
Walter Roberson
Walter Roberson 2019년 11월 26일
Have you considered the possibility of naming the function parameter NumberOfPoints ?
Roger Nadal
Roger Nadal 2019년 11월 26일
I didn’t understand?

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

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

질문:

2019년 11월 25일

댓글:

2019년 11월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by