Answered step by step
Verified Expert Solution
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 "Inamefnamelabcomparison.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.
Inamefname lab comparison.m
: Compares tw calculations with initialized and
uninitialized arrays.
clear; Clear all variables
maxcount ; Number of repetitions
tic; Start timer
for : maxcount
for ii :
square ; Calculate square
end
end
toc; Ends timer and writes out the elapsed time
clear square; Clear output array
tic; Start timer
square zeros ; Initialize the array
for :maxcount
for :
squareii ii; 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 "Inamefnamelabpprocessing.m
Point processing is a linear or nonlinear image manipulation method that is applied to
individual pixels.
Background
RGB imreadfilename: 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
dimensional matrix.
c Implement your own code to apply below point filters.
d Use tictoc function to log execution time of each filter.
e Comment on the results and execution time IN DETAIL.
STEP : Accumulate input data
Initialize to zero, initialize array numbersx to dimension array.
Prompt user for first positive number and note that "Entering will end the process."
Read in first
while
nlarrn
Prompt user for next number
Read in next
End
STEP : Calculate mean and Standard Deviation
bar larr sumx n
stddev larr sqrt FILL IN THE BLANKS
STEP: Write Out the results
Write out the mean value xbar
Write out the standard deviation stddev
Write out the number of input data points
Additional Questions:
List the conditions when above program will fail.
How can you avoid these possible errors programmatically and change exit flag to
any letter?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started