4) (5 pts) Using the function from part 3, compute precision for a reference val
ID: 2257150 • Letter: 4
Question
4) (5 pts) Using the function from part 3, compute precision for a reference value equal to 1.0 to le-30, reducing it by a factor of 10 each step. (base base/10.0;) Write out the results of each case to a Comma Separated Values (CSV) file Write out the precision, and the base, along with the ratio of precision and base, in other words write out base, precision and precision/base. Document these results in your report. First, plot the base versus precision and then plot base versus the ratio. Consider the form and style of plot you are using, especially the x-axis. Due to the geometric nature in the progression of base, base/10 at each step, a log scale might be helpful. The MATLAB function loglog is the same as plot, except each axis (x and y) will use a log scale. Describe the results of this experiment, and explain which term is more meaningful, precision or precision/base. * Files with the CSV extension (file.csv) are recognized by almost all programs, such as Excel. These are simple text files with the numerical values separated by commas. Some of the basic of writing a csv file are included here.Explanation / Answer
Double2CSV.m
function Double2CSV(x,name)
[n,m] = size(x);
fid = fopen(name,'w');
if fid != 0
for h = 1:n
for k = 1:m-1
fprintf(fid,'%18.16g', x(h,k));
end
fprintf(fid,'%18.6g ',x(h,m));
end
fclose(fid);
end
x=[0:0.01:1;exp(0:0.1:1)]
Double2CSV(x, 'ExpTest.csv')
plot(x(:,1),x(:,2))
grid
title ('Exponential o x')
xlabel('x')
ylabel('exp(x)')
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.