Question Details

(Solved by Expert Tutors) Matlab questions: Please see the attached file for questions. 1.Wr


1.Write

a script that will prompt the user for a positive number n and a trigonometric function name, such as sin, cos, tan or cot. Create a vector x of 1000 linearly equally spaced points between 0 and n, and a vector y which is either sin(x), cos(x), tan(x) or cot(x), depending on user specification. Then plot with a title that says, e.g. ?sin(x) from [0, n]? where the value of n is actually in the title.?
2.Write a function wordscramble that will receive a word in a string as an input argument. It will then randomly scramble the letters and return the result. Here is an example of calling the function:
>> wordscramble('fantastic') ans =
safntcait?
3.Write a function called mygalaxy to create a model galaxy and return the assigned mass, coordinates, and calculated resultant gravitational force for each star. The call to the function should have the form:
[mass coord force] = mygalaxy(N, dimX, dimY, dimZ)
Input arguments are the number of stars in the galaxy, N, and the galaxy dimensions dimX, dimY, and dimZ. The output values are the mass, mass, the Cartesian coordinates, coord, and resultant force vector, force, associated with each star.
The dimensions of output vector mass should be Nx1, so that, for instance, mass(43) stores the assigned mass of the 43rd star. The dimensions of coords and force should be [Nx3], so that, for example, coord(54,2) stores the y-coordinate of the 54th star, and force(12,3) stores the z-coordinate of the resultant gravitational force on the 12th star.
The function mygalaxy should use MATLAB function rand to generate the mass and the coordinates for all N stars. The mass of each star should be in the range m ? ?1 ? 1030 , 1 ? 1032 ? (kg), whereas
the coordinates should be in the range x ? ?0, dimX ? , y ? ?0, dimY ? , z ? ?0, dimZ ? (meters). The resultant gravitational force Fi acting on any given star i can be computed using Newton?s Law
of Universal Gravitation, which, extended to a system of stars, takes the form:
F??NGmimj rij
i
j?i
2
rij
j ?1 rij
In the equation above, G = 6.67408 ? 10-11 m3 kg-1 s-2 is the universal gravitational constant, mi and m j are the masses of stars i and j , respectively, and rij is the displacement vector between the two
stars, which should be computed in a subfunction called dispvec, according to the formula: rij ??xj ?xi, yj ?yi, zj ?zi,?.
Call your function passing to it the following values for input arguments:
N = 100;dimX = 1e9;dimY = 1e9;dimZ = 1e9;Using fprintf with formatting, print to screen the mass, coordinates, and force components for a random star of your galaxy.
Display the time it took the CPU to perform the programmed computations. This time can be calculated using the tic and toc functions of MATLAB.
Now, repeat the call to the function, but setting N = 1000.?

 


Solution details:

Pay using PayPal (No PayPal account Required) or your credit card . All your purchases are securely protected by .
SiteLock

About this Question

STATUS

Answered

QUALITY

Approved

DATE ANSWERED

Apr 19, 2020

EXPERT

Tutor

ANSWER RATING

YES, THIS IS LEGAL

We have top-notch tutors who can do your essay/homework for you at a reasonable cost and then you can simply use that essay as a template to build your own arguments.

You can also use these solutions:

  • As a reference for in-depth understanding of the subject.
  • As a source of ideas / reasoning for your own research (if properly referenced)
  • For editing and paraphrasing (check your institution's definition of plagiarism and recommended paraphrase).
This we believe is a better way of understanding a problem and makes use of the efficiency of time of the student.

NEW ASSIGNMENT HELP?

Order New Solution. Quick Turnaround

Click on the button below in order to Order for a New, Original and High-Quality Essay Solutions. New orders are original solutions and precise to your writing instruction requirements. Place a New Order using the button below.

WE GUARANTEE, THAT YOUR PAPER WILL BE WRITTEN FROM SCRATCH AND WITHIN A DEADLINE.

Order Now