how do i salve this?
Show older comments
Answers (1)
David Hill
on 22 Feb 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 Comments
Walter Roberson
on 22 Feb 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
on 22 Feb 2021
The requirement to not use any built-in MATLAB functions does not merely make the task difficult: it makes it impossible.
Categories
Find more on String Parsing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!