Why doesn't my function work?

조회 수: 1 (최근 30일)
Julen Vicente Pipaon
Julen Vicente Pipaon 2021년 3월 7일
댓글: Julen Vicente Pipaon 2021년 3월 7일
This is how I call my function.
>> X=4;
>> pepe(X)
But it tells me: Undefined function or variable 'pepe'.
I don't know what I am doing wrong.
THIS IS MY CODE:
function [i,j,n] = pepe(X)
n=0;
for i=1:X
for j=1:X
a(i,j)= 1+n;
n = n+1;
end
end
for i=2:X
for j=1:X
a(i,j)= a(i-1,j)
end
end
n=2;
for j=1:X
for i=n:X
a(i,j)= 0
end
n=n+1;
end
end
  댓글 수: 2
Walter Roberson
Walter Roberson 2021년 3월 7일
편집: Walter Roberson 2021년 3월 7일
Which file did you store function pepe in ? And is it in your current directory?
Julen Vicente Pipaon
Julen Vicente Pipaon 2021년 3월 7일
Oh. I stored it with a diferent name so thats why it wasn't working.
I thougth my code had an error.
Thank you.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by