Create Number and excluding
5 views (last 30 days)
Show older comments
Commented: Steven Lord on 22 Mar 2023
hi everyone hope you can help me i know this request is very simple but i am new. I want to generate a sequence of numbers from 5 to 15 and remove numbers 9 and 13 using for and while . loops Thank you everyone
Steven Lord on 22 Mar 2023
This sounds like a homework assignment because of your insistence on using for and/or while loops. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the free MATLAB Onramp tutorial to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.
Antoni Garcia-Herreros on 22 Mar 2023
Not sure why you would like to do this using a loop, but anyways:
l=5:15; % Array containing the values from 5 to 15
% you can always delete the elements doing l(5)=;
ll=5:15; % Array containing the values from 5 to 15
lll=zeros(size(ll,2)-2,1); % Array where your result will be stored
if ll(i)==9 || ll(i)==13
More Answers (1)
David Hill on 22 Mar 2023
No need for loops.
Find more on Creating and Concatenating Matrices 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!