Question: MATLAB Problem Conversions : 80 yens are worth one dollar, one German mark is worth 62.42 yens, and one euro is worth 1.95583 German marks.
MATLAB Problem
Conversions: 80 yens are worth one dollar, one German mark is worth 62.42 yens, and one euro is worth 1.95583 German marks.
Use these conversions to construct a program that converts dollars to yens, yens to german marks then to dollars, and german marks to euros and then to dollars. Make a conversion table for dollars = [0:1:100] to yens, german marks and euros.
Use the anonymous function syntax to create the appropriate functions. Use well-formatted print commands, print your results in an external file in steps of 1 dollar from [0,10] and in steps of 10 dollar from [10,100].
Please debug the following solution to get the right results
SOLUTION FOR DEBUGGING
% Currency Conversion Table
% Converts dollars to different currencies
% D [dollars], G [german marks], E [euros]
% File: Currency3Debugging.m
clc, clear
FID=fopen('ConversionTable2.txt','w');
Y=@(D) D.*80; % converts Dollars to Yens
G=@(D) Y(D)./62.42; % converts Dollars to Yens and then Yens to German Marks
E=@(D) G(D)./1.95583; % converts Dollars to German Marks and then GM to Euros]
D=[0,100]; % dollar vector
fprintf(FID,'%9s %9s %9s %9s ','Dollar', 'Yen', 'Mark','Euro');
jj=20; % aux variable to jump 10 by 10
for ii=1:numel(D)
if ii
fprintf(FID,'%9.2f %9.2f %9.2f %9.2f ',D(ii), Y(D(ii)),G(D(ii)), E(D(ii)));
else
if ii==jj
fprintf(FID,'%9.2f %9.2f %9.2f %9.2f ',D(ii), Y(D(ii)),G(D(ii)), E(D(ii)));
jj=jj+10; % jumps 10 by 10 and reduce output results
end
end
end
fclose(FID);
A sample of the correct solution is shown in Appendix-1.

APPENDIX-1 A sample of the correct solution Currency2.m ConversionTable2.txt 1+ Dollar 0.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 Mark 0.00 1.28 2.56 3.84 5.13 6.41 7.69 8.97 10.25 11.53 12.82 25.63 38.45 51.27 64.08 76.90 89.71 102.53 115.35 128.16 Yen 0.00 80.00 160.00 240.00 320.00 400.00 480.00 560.00 640.00 Buro 0.00 0.66 1.31 1.97 2.62 3.28 3.93 4.59 5.24 5.90 6.55 13.11 19.66 26.21 32.76 39.32 45.87 52.42 58.98 65.53 2 3 4 6 7 10 720.0 12 13 14 15 16 17 18 19 20 21 800.00 20.00 1600.00 30.00 2400.00 40.00 3200.00 50.00 4000.00 60.00 4800.00 70.00 5600.00 80.00 6400.00 90.00 7200.00 100.00 8000.00
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
