Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is in MATLAB !! Need help with this. I know how to do MATLAB prime numbers normally, but I do not know how to
This is in MATLAB!! Need help with this. I know how to do MATLAB prime numbers normally, but I do not know how to do the prime numbers with the required functions and method, (ex. the NaN function, and floorsqrt(n) function, etc...) Im not sure how to store the non prime numbers in an array either. Please make sure to fully read the prompt for all specific requirements, they are highlighted. Please run your code through MATLAB to make sure it works, it doesnt help if I get incomplete or partial script. Thank you.
Question 2 You will improve on the previous C++ primes assignment by implementing a different algorithm. Find prime numbers in this assignment and store them within an array. Assume you are finding all the prime number 20. Starting at 2, set all multiples of 2 larger than 2 to NaN. 2 3 4 5 Y6 7 8 9 N00 11 12 13 14 15 M6 17 N8 19 20 Then do that again for the next higher number, 3 2 3 4 5 6 7 8 9 No 11 12 13 H4 15 16 17 18 19 20 And then again for 4 and so on up to floor (sart (n) using a nested for loop At the end of this, all values that are not NaN at some stage is a prime on n. Then you must use isnan to identify and filter NaN values, and restore the prime array that contains only numbers. Write this code into a script named hw10b.m. Sample output: Enter a number: 20 Prime numbers are: 13 17 19 11Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started