필터 지우기
필터 지우기

undefined function or variable 'N'

조회 수: 2 (최근 30일)
Mitul Dattani
Mitul Dattani 2017년 11월 15일
답변: KSSV 2017년 11월 15일
why do i get the error in the title. I also tried iteration(n), the file is named the same aswell and I cant seem t get past the error message.
function iteration
% Summary of this function goes here
% Detailed explanation goes here
% Sum variable put to 0
S = 0;
% Input n
n = input('Please give the nuber of iterations: ');
%the sum is constructed
for k=0:n
S=S+(1+(4/(S+1)));
end
end

답변 (1개)

KSSV
KSSV 2017년 11월 15일
function S = iteration(n)
% Summary of this function goes here
% Detailed explanation goes here
% Sum variable put to 0
S = 0 ;
%the sum is constructed
for k=0:n
S=S+(1+(4/(S+1)));
end
end
Now call it by:
n = 10 ;
S = iteration(n) ;

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by