Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using MATLAB do the following: Example:the following function sorts the elements of a vector in ascending order function v - gsort(v) while pos 2 %

Using MATLAB do the following:

image text in transcribed

Example:the following function sorts the elements of a vector in ascending order

image text in transcribed

function v - gsort(v) while pos 2 % decrease position pos pos 1; end end end For and while loops can be interrupted with the break statement. Generally, for and while loops should be avoided in MATLAB as they are very slow. Instead you should try to use built-in MATLAB functions or vectorize the code with the dot-operator 5.3 Exercises 1. Extend the factorial function defined above, such that it checks for a positive input argument 2. Write a function that calculates a random walk trajectory based on the iteration x-rite, where e is a uniformly distributed random variable between -1 and 1. Plot the resulting trajectory. 3. Change the sorting algorithm given above such that it sorts the elements in descending order Compare the speed of your function with the built-in MATLAB function sort 4. Approximation of T. The area of a circle is given by A-tr2 where r is the radius. Assume a circle with r 0.5 embedded in a unit square. A point in the unit square is defined by p-(x,y) where 0-2, y

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Third International Conference Achids 2011 Daegu Korea April 2011 Proceedings Part 2 Lnai 6592

Authors: Ngoc Thanh Nguyen ,Chong-Gun Kim ,Adam Janiak

2011th Edition

3642200419, 978-3642200410

More Books

Students also viewed these Databases questions

Question

Which message-sending behavior do I want to improve the most?

Answered: 1 week ago

Question

4. Choose appropriate and powerful language

Answered: 1 week ago

Question

2. Choose an appropriate organizational pattern for your speech

Answered: 1 week ago