MatLAB | Mathematica | MathCAD | Maple Answers

Questions: 124

Answers by our Experts: 124

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Two cars head in different directions. Car 1 averages 47.3 miles/hr on a direction of 225 degrees true, while car 2 averages 64.2 miles/ hr. After 2.50 hours it is known that they are 232 miles apart. Find the direction ( bearing that car 2 was headed, assuming that it was between 090 degrees true and 180 degrees true
High tide occurs at 8:00 AM and is 1 m above sea level. Six hours later, low tide is 1 m below sea level. After another 6 hours, high tide occurs again 1 m above sea level, then finally one last tide 6 hours later 1 m below sea level. A) write a mathematical expression that would predict the level of the ocean at this beach at any time of the day. B) find times in the day when the ocean level is exactly at sea level.
Write MATLAB scripts for the following:

To accept two numbers from the user and display armstrong number between these numbers
Write a MATLAB script to display currency conversion for US Dollar, British Pound, Euro with Singapore Dollar as the base Currency. Your output should show the equivalent values for USD, GBP, EURO for every Singapore dollar in increments of 1 dollar until 25 dollars.
In this part, you will use logical vectors to make multiple decisions in parallel concerning values in two arrays. Firstly, generate two random [1x10] arrays using randi. The numbers should be integers between 0 and 100. Let’s call these two arrays a1 and a2.
Your task is to generate a third array, a3, which at each index, contains the largest number out of the two earlier arrays. You must accomplish this using a logical vector and no loops.

An example snippet of code that would accomplish the same task, with a for-loop, is given below:

% For each index i, the corresponding a3
% value will be the larger of a1(i), a2(i)
for i=1:10
a3(i) = max(a1(i),a2(i));
end

Hint: try constructing a logical vector of size [1x10] to store logical values based on if a1(i) > a2(i)
Create three scripts with the program code from the third example (3-D array) in Part 3.

 In one script, copy-and-paste the nested for-loop 3-D array program as given below.

 In the second script, add the array pre-allocation version of the program

 In the third script, insert your vectorised version of the program

Now, experiment with increasing the value of n in the original nested for-loop program, until the execution time takes over 3 seconds to run. To do this, either use the “Run and Time” button on the Editor tab – or use the tic and toc commands. Now run the equivalent second and third scripts (for the same value of n). How much faster is the vectorised solution compared with the original program code?

% 3-D array where
% C(i,j,k) = i*j+k
n = 10;
for i=1:n
for j=1:n
for k=1:n
C(i,j,k) = i*j+k;
end
end
end
Now, for each of the for-loop examples on the next page, write two programs that generate the same arrays (1-D, 2-D and 3-D), with the following changes:
1. Modify the programs to pre-allocate the arrays first
2. Use vectorisation functions to implement the programs without the use of any loops. You may want to
look at ndgrid, and remember to use array versions of your operators!

% 1-D array (3 * i)
n = 10;
for i=1:n
A(i) = 3*i;
end

% 2-D array where
% B(i,j) = i/j
n = 10;
for i=1:n
for j=1:n
B(i,j) = i/j;
end
end

% 3-D array where
% C(i,j,k) = i*j+k
n = 10;
for i=1:n
for j=1:n
for k=1:n
C(i,j,k) = i*j+k;
end
end
end
Create a nested for-loop script to iterate through all values of i=1:20 and j=1:20. Also start with a
running tally of total=0.
At each iteration, check the value of j. If j is divisible by 3, then do nothing and proceed to the next value of j. Next, if i x j is greater than 100, then stop processing the current j-based for-loop, and move on to the next value of i.
If both conditions have not been met, then add both i and j to the running tally called total. What is your final value for total at the end of your script? And how many times did MATLAB execute the break and continue statements in your program?
Write MATLAB programs to find the following sums with for loops and by vectorization. Time both versions in each case.
1^2 + 2^2 + 3^2 +· · ·+ 1000^2 (sum is 333,833,500).

1 − 1/3 + 1/5 - 1/7 + 1/9 -· · ·- 1/1003 (sum is 0.7849—converges slowly to π/4).

Sum the left-hand side of the series:
(1/1^2.3^2) + (1/3^2.5^2) + (1/5^2.7^2) +· · ·=(pi^2 - 8)/16 (sum is 0. 1169 − with 500 terms).
Create a function to plot the output of projectile motion with inputs x0, y0, v0x and v0y. These correspond to the (x, y) coordinates of the projectile’s start location, as well as the initial velocities in each direction. You may assume zero acceleration in the x-direction, and acceleration in the y-direction is -g ݃ where g=9.81.
Use a time series vector (1D array) to denote time, and two vectors to denote the movement in the x-direction and y-direction. Your plot should only show the trajectory until the projectile object reaches the ground.
LATEST TUTORIALS
APPROVED BY CLIENTS