# can any one tell me why that function can not run??

3 visualizaciones (últimos 30 días)
Hasnaa Hasaan el 8 de Dic. de 2022
Movida: John D'Errico el 8 de Dic. de 2022
n=-5:5;
x=y(n);
x1=y(n-1);
x2=y(n+1);
subplot(3,1,1)
stem(n,x);
grid on;
subplot(3,1,2)
stem(n,x1);
grid on;
And I have the following function
function x=y(n)
x(n)=(n).*(n>=1&n<=5);
end
##### 1 comentarioMostrar NingunoOcultar Ninguno
Hasnaa Hasaan el 8 de Dic. de 2022
Movida: John D'Errico el 8 de Dic. de 2022
Thank you all for you cooperation

Iniciar sesión para comentar.

Stephen23 el 8 de Dic. de 2022
Editada: Stephen23 el 8 de Dic. de 2022
x(n) = ..
^^^ because of this indexing
Fixed:
n=-5:5;
x=y(n);
x1=y(n-1);
x2=y(n+1);
subplot(3,1,1)
stem(n,x);
grid on;
subplot(3,1,2)
stem(n,x1);
grid on; function x=y(n)
x = (n).*(n>=1&n<=5);
end
##### 1 comentarioMostrar NingunoOcultar Ninguno
Hasnaa Hasaan el 8 de Dic. de 2022
Thank you it is done..much appreciated

Iniciar sesión para comentar.

### Más respuestas (1)

Jiri Hajek el 8 de Dic. de 2022
Hi, you obviously did not do any debugging. Your attempt at coding has several issues, but you can easily rectify them if you go obe line of the code at a time and have a look at its result. Matlab provides you a preview of the values of variables and you have the workspace panel with all your variables, where you can see all variables that currently... Use F10 or F11 to step through your code and see the results line by line. It will become much clearer.
##### 0 comentariosMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Box Plots 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!