Question

homework assignment (HW6), but this time using a vectorized approach. Write a script that prompts the user for N integers (MATLAB

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

close all
clear all
clc
N=input('Enter N: ');
cnt=0;
arr=[];
while(cnt~=6)
num=input('Enter integer: ');
if(floor(num)~=num)
disp('Error non integer value');
continue;
end
arr=[arr num];
cnt=cnt+1;
end
negnums=arr(find(arr<0))
posnums=arr(find(arr>0))

MATLAB R2018a EDITOR ② ▼| rch Documentation Log In Find Files Compare Print Run Section New Open Save Advance Run and Find In

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
MATLAB homework assignment (HW6), but this time using a "vectorized" approach. Write a script that prompts...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in matlab (a)Write a function to generate n random integers between -b and b. (b) Using...

    in matlab (a)Write a function to generate n random integers between -b and b. (b) Using the function you wrote in (a) generate 50 random numbers in a vector A where b = 100; (c) This array A will contain both negative, positive and possibly zero entries. Write a MATLAB script to compute the percentage of positive, negative and zero entries in the array.

  • Write a script that prompts the user to enter a value n (n > 6) that...

    Write a script that prompts the user to enter a value n (n > 6) that will generate an n element vector of random integers between 0 and 100 that will represent quiz grades. Then have the script calculate the average of the quizzes where the smallest grade is dropped. Then script will display the average of the quizzes along with the highest quiz grade. Given the following system of equations: 8s - 11t + 7u + 5v - w...

  • Using Matlab or Octave, I do not know how to write the script for this problem,...

    Using Matlab or Octave, I do not know how to write the script for this problem, please help. Must match sample output 5. Consider a 3 x 3 matrix given by A = 01 012 013 az az 633 ( dai 632 033 The trace of A is defined as tr(A)=2au. Given another 3 x 3 matrix bu bı2 bia B- bi brz bra | bgi bz2 by it can be shown that trAB') = tr(AB). Write a script that...

  • Please use Matlab to solve and show your full codes Write a script file Ask the...

    Please use Matlab to solve and show your full codes Write a script file Ask the user to enter sides of a triangle: a, b, c Check to see if the sides are all greater than 0 If they are: Use the function (triangle) that you created in your last homework problem (HW#5 problemttF) to calculate the area. command Display the results on the screen using fprintf write the results to disk using the fprintf command. If any of the...

  • Please answer 1c, use MATLAB, and paste your entire script in your answer so that I...

    Please answer 1c, use MATLAB, and paste your entire script in your answer so that I can copy and paste to see if it works. Problem #1 400g triangle square pentagon hexagon Figure 1 For a closed geometric figure composed of straight lines (Figure 1), the interior angles in the figure must add to (n-2)(180) where n is the number of sides. Required Tasks a) Write a script that prompts the user to select from one of the following shapes:...

  • Write a C program that prompts the user to enter a series of integers that represent...

    Write a C program that prompts the user to enter a series of integers that represent a coded message. I have given you the decoder program so that you can see how it is written using array notation. Your assignment is to convert the code to a program that uses only pointers and pointer math. Your program must use pointer notation and pointer math (i.e. no array index notation other than in the declaration section, no arrays of pointers and...

  • 1) a) Write MATLAB function that accepts a positive integer parameter n and returns a vector...

    1) a) Write MATLAB function that accepts a positive integer parameter n and returns a vector containing the values of the integral (A) for n= 1,2,3,..., n. The function must use the relation (B) and the value of y(1). Your function must preallocate the array that it returns. Use for loop when writing your code. b) Write MATLAB script that uses your function to calculate the values of the integral (A) using the recurrence relation (B), y(n) for n=1,2,... 19...

  • C Programming Quesition (Structs in C): Write a C program that prompts the user for a...

    C Programming Quesition (Structs in C): Write a C program that prompts the user for a date (mm/dd/yyyy). The program should then take that date and use the formula on page 190 (see problem 2 in the textbook) to convert the date entered into a very large number representing a particular date. Here is the formula from Problem 2 in the textbook: A formula can be used to calculate the number of days between two dates. This is affected by...

  • USING MATLAB: Many organizations sell candy for fundraisers. Often the items are purchased in bulk to...

    USING MATLAB: Many organizations sell candy for fundraisers. Often the items are purchased in bulk to cut cost and suppliers offer quantity discounts. 1-5 bars = $ 0.75 each 6-10 bars = cost of 5 bars + $0.50 each additional 11-15 bars = cost of 10 bars + $0.40 each additional More than 15 bars = cost of 15 bars + $0.30 each additional Starting with the function n = input('How many candy bars would you like to buy? ')...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT