how do i salve this?

1 visualización (últimos 30 días)
Joseph Capp
Joseph Capp el 22 de Feb. de 2021
Comentada: Walter Roberson el 22 de Feb. de 2021

Respuestas (1)

David Hill
David Hill el 22 de Feb. de 2021
I assume you cannot use the built-in function movsum()
movsum(x,3,'Endpoints','discard');
But should be able to use other functions.
prs3=[];
for k=1:length(x)-2
c=0;
for m=0:2
c=c+x(k+m);
end
prs3(k)=c;
end
  2 comentarios
Walter Roberson
Walter Roberson el 22 de Feb. de 2021
prs3=[];
Literal [] appears to be a syntactic construct with the [] not executed to produce an empty array. The above line indeed does not execute any defined function.
for k=1:length(x)-2
That executes the built-in functions length() and minus() and colon() . However, for itself and what is written as an assignment do not execute any defined function.
c=0;
Numeric values are constructed at parse time rather than at execution time, and non-subscripted assignment does not execute any defined function.
for m=0:2
Numeric functions are constructed at parse time, and for itself does not involve executing any defined function. However, that involves executing the function colon()
c=c+x(k+m);
That involves executing the function plus() and subsref() and plus()
end
No defined function for that line
prs3(k)=c;
That involves executing the function subsasgn()
end
No defined function for that line.
List of prohibitted functions executed:
  • colon
  • length
  • minus
  • plus
  • subsasgn
  • subsref
Walter Roberson
Walter Roberson el 22 de Feb. de 2021
The requirement to not use any built-in MATLAB functions does not merely make the task difficult: it makes it impossible.

Iniciar sesión para comentar.

Categorías

Más información sobre String Parsing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by