a) Just type r=[5:400]' in command window. It creates a column vector of integers from 5 to 400. If you want row vector just type r=[5:400]
b) To create a function in MATLAB, first open m file and save it with name 'integerdivision'
now type following commands and SAVE
function [s,p]=integerdivision(a,b)
[s,p] =deconv(a,b);
let us test it. let the polynomial is 2x3+7x2+4x+9 divided by x2+1. Answer is quotient=2x+7
and remainder 2x+2. Now take another m file and type following (coefficient vectors n and d while r and q are remainder and quotient values obtained from function)
n=[2 7 4 9];
d=[1 0 1];
[r,q]=integerdivision(p,q)
answer pops in command window as
r =
2 7
q =
0 0 2 2
d) to find roots use roots function. Type following in command window
t=[1 2 -5 7 12 20];
k=roots(t)
2) a) type following in m file and run
a=[2,4,10,13; 16,3,7,18;8,4,9,25;3,12,15,17];
length(a)
size(a)
b=a(2:3,1:3)
b(5)
Output in command window is
ans =
4
ans =
4 4
b =
16 3 7
8 4 9
ans =
7
integers between 5 and 400 Use MATLAB command windows to create a vector with all a)...
6. Write a function integerdivision that takes two input numbers and divides the first one with the second one. Question 2 a) Create a vector A with all integers between 5 and 400. 4 Marks ) Given a matrix Z, how to access element of the matrix. c) What is the output of this MATLAB code? A [2,4,10,13;16,3,7,18, 8,4,9,25:3,12,15,17); length(A) size(A) Ans) Ans)
6. Write a function integerdivision that takes two input numbers and divides the first one with the...
You have the matrix below: a) 9 10 11 12 What will be displayed by the code: A(2:3,2:3) What will be displayed when you run the code below? b) a-0 while a<10 aa+3: end disp (a) d) Give the steps to find the roots of the following linear equation using MATLAB. rs + 2x4-5x3 + 7x2 + 12x + 20 = 0 a) Give MATLAB commands to plot, on the same figure, the two functions: f(t) = 3t2 +2t-0.5 g(c)-2t...
The matlab code for the following problem is
appreciated!!
QUESTION 3 Write a function fnfr_plot that will receive two function handles from elementary math functions which accept a vector to first sort in ascending order then calculate. The script will display the results in two separate Figure Windows with the function names in the title. Submit: fnfr_plot.m Browse My Computer Attach File QUESTION 4 Generate 1x100 random vector, x in the range of 0<x<100 by using rand. Input 2 elementary...
MATLAB Problem
HW7P2 (20 points) (5 pts) Write a user-defined MATLAB function called HW7P2_fn for the following math function 3 o-0.47x The input to the function is x and the output is y. Write the function such that x can be an array (use element-by-element operations) (15 pts) Use the function in (a) the command window to calculate y(-2) and y(5) (b) a script file HW7P2.m to determine y(x) for 0.001 Sx S 10 with 1000 points. Hint: Use the...
MATLAB
Define the following computer programming terms and give an example of each. MATLAB example Sequence Selection structure- Repetition structure - Relational operators (True = 1, False = 0) Logical operators (True = 1, False =0) And Or Less than Less than or equal to Greater than Greater than or equal to Equal to Not equal to Not ans ans Type the following relational operator commands into MATLAB in the command window one at a time. Write the results to...
use MatLab to answer these questions
1. (10 points) Create an m-file called addup.m Use a for loop with k = 1 to 8 to sum the terms in this sequence: x(k) = 1/3 Before the loop set sumx = 0 Then add each term to sumx inside the loop. (You do not need to store the individual values of the sequence; it is sufficient to add each term to the sum.) After the loop, display sumx with either disp()...
Create a program SearchNewBooks.cc that given as command line input newbooks.dat and request.dat and a method of search either binary or linear, creates a file of the number of books found from the request list. program should receive two filenames as command line arguments, the new books file and request file, which the program should read in. The list of new books and list of requested books should should be stored in only two std::vector containers. Because some code to...
Please show matlab editor and command window
B. (4 pts) Use the : operator to create the vectors x [2.5,1.50.5,-0.5,-1.51 and y [0.4,0.8,1.2,1.6,2], then use them in the following expression to compute vector z using element-by-element calculations C. (8 pts) A 70 lb bag of rice is being pulled by applying a force F at an angle θ as shown. The force required to drag the bag is given by: θ μ sin θ + cos θ Where u-0.35 is...
Nay
programming languge is fine (MatLab, Octave, etc.)
This is the whole document this last picture i sent is the
first page
5. Write and save a function Sphere Area that accepts Radius as input argument, and returns SurfaceArea (4 tt r) as output argument. Paste the function code below. Paste code here 6. Validate your Sphere Area function from the command line, checking the results against hand calculations. Paste the command line code and results below. 7. Design an...
Use matlab
a) Create a simulated data set b) Create a set of plots to determine the best transformation to linearize the data c) Fit a first order polynomial (y mx + b) to the linearized data to find the constants m and b d) Reconstruct the original equation from m and b in the linear fitted polynomial e) Plot the fitted equation. Radioactive decay is modeled by the equation: rt where A the amount of mass as a function...