Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In MATLAB: I have two files that need to downloaded and read into MATLAB. What i

ID: 3861882 • Letter: I

Question

In MATLAB:

I have two files that need to downloaded and read into MATLAB. What is the procedure and code for doing this? The first file is "Data01.csv" and it is a text file, the second file is "Data02.mat" and it is a binary file. The time needs to be recorded to read each file.

The two files were written from MATLAB, using the same data and thus should contain the same numbers. Compute the Maximum Absolute Relative Error (MaxARE) between the data from the two files, assuming that the binary (Data02) data is more accurate. What is the code and procedure for this?

Explanation / Answer

% If you have sample data files then please provide sample data files.

% Also specify formula that you have used to evaluate MaxARE

clc;

clear all;
close all;
fname = 'Data01.csv'; % File name
fid = fopen(fname); % Open File with the filename ID
M = textscan(fid, '%f'); % Scan Each column data as floating point data, Store complete data into cell format
data_csv=cell2mat(M); % Convert Cell data into matrix format
fclose (fid); % Close Current File

fname1 = 'Data02.mat'; % File name
fid1 = fopen(fname1); % Open File with the filename ID
M = textscan(fid1, '%f'); % Scan Each column data as floating point data, Store complete data into cell format
data_mat=cell2mat(M); % Convert Cell data into matrix format
fclose (fid1); % Close Current File
disp([data_csv data_mat]); % Display Data of CSV file and MAT file

% Formula I am considering is = 100*((TRUE_value-VALUE)/TRUE_value);
Max_Abs_Rel_Error= ( sum(abs(data_mat-data_csv))/(sum(abs(data_mat))) )*100;
fprintf('Maximum Absoulte Relative Error : %f ',Max_Abs_Rel_Error);

Data02.mat

1.05 2.0001 3.0002 4.00056 5.00078 6.2 7.0 8 9
10.0001 11 12 13.0001 14 15 16
17 18.0001 19 20 21.0001 22 23

Data01.csv

1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23

----Output

1.0000 1.0500
2.0000 2.0001
3.0000 3.0002
4.0000 4.0006
5.0000 5.0008
6.0000 6.2000
7.0000 7.0000
8.0000 8.0000
9.0000 9.0000
10.0000 10.0001
11.0000 11.0000
12.0000 12.0000
13.0000 13.0001
14.0000 14.0000
15.0000 15.0000
16.0000 16.0000
17.0000 17.0000
18.0000 18.0001
19.0000 19.0000
20.0000 20.0000
21.0000 21.0001
22.0000 22.0000
23.0000 23.0000

Maximum Absoulte Relative Error : 0.091236

>>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote