Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Pseudocode:Loops and Vectorized code Comparison [ Execute this question in a new script named Iname _ fname _ lab 4 _ comparison.m ] Problem:

Pseudocode:Loops and Vectorized code Comparison
[Execute this question in a new script named "Iname_fname_lab4_comparison.m"]
Problem: Run the code given below. Investigate the time cost of two calculations:
a) With uninitialized array
b) With initialized array
c) Write a comment about why it takes different amount of time.
% Iname_fname lab3 comparison.m
: Compares tw calculations with initialized and
uninitialized arrays.
clear; % Clear all variables
maxcount =10;% Number of repetitions
tic; % Start timer
for jj=1: maxcount
for ii =1:10000
square (ii)=ii???2; Calculate square
end
end
toc; Ends timer and writes out the elapsed time
clear square; % Clear output array
tic; % Start timer
square = zeros (1,10000); Initialize the array
for jj=1 :maxcount
for ii=1:10000
square(ii)= ii^2; % Calculate square
end
end
toc; Ends timer and writes out the elapsed time
Background
tic: tic starts a stopwatch timer to measure performance. The function records the internal
time at execution of the tic command.
toc: Display the elapsed time with the toc function.
Example:
tic;
staments ; .....
toc;Introduction to Programming - Lab Manual
Point Processing
[Execute this question in a new script named "Iname_fname_lab4_p_processing.m"]
Point processing is a linear or non-linear image manipulation method that is applied to
individual pixels.
Background
RGB = imread(filename): The standard MATLAB function reads the image and loads it to
the workspace.
Problem:
a) Take your selfie (RGB domain) and load image.
b) Use "whos" function to learn about image size and RGB layer locations in the n
dimensional matrix. (mxn3)
c) Implement your own code to apply below point filters.
d) Use tic-toc function to log execution time of each filter.
e) Comment on the results and execution time IN DETAIL.
STEP -1: Accumulate input data
Initialize n to zero, initialize array numbers_x to 0 dimension array.
Prompt user for first positive number and note that "Entering -1 will end the process."
Read in first x
while x0
nlarrn+1
-?x[n]=x
Prompt user for next number
Read in next x
End
STEP -2: Calculate mean and Standard Deviation
,x?bar larr sum_x / n
std_dev larr sqrt( FILL IN THE BLANKS )
STEP-3: Write Out the results
Write out the mean value x_bar
Write out the standard deviation std_dev
Write out the number of input data points n
Additional Questions:
List the conditions when above program will fail.
How can you avoid these possible errors programmatically and change "-1" exit flag to
any letter?
image text in transcribed

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

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions