Borrar filtros
Borrar filtros

undefined function or variable 'N'

2 visualizaciones (últimos 30 días)
Mitul Dattani
Mitul Dattani el 15 de Nov. de 2017
Respondida: KSSV el 15 de Nov. de 2017
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

Respuestas (1)

KSSV
KSSV el 15 de Nov. de 2017
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) ;

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by