Issue with plotting. I put it in a vector but it returns a scalar once it goes through the calculation

조회 수: 1 (최근 30일)
Hi everyone
I wanted to plot this program. My N ranges from 1 to 60 and the function is set below it. However it only runs when N=60. Like i don't get a vector from er
%%%%%%%%%%%
x = 10;
N = [1:60]
sumN = x.^N/factorial(N);
er =abs(sumN-exp(x))/exp(x);
plot(N,er,'*')

채택된 답변

Tommy
Tommy 2020년 4월 4일
Add a dot before the division symbol in the third line for element-wise division:
x = 10;
N = [1:60]
sumN = x.^N./factorial(N);
er =abs(sumN-exp(x))/exp(x);
plot(N,er,'*')

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by