Following the introduction provided by the screencast, create an m-file that loa
ID: 2079236 • Letter: F
Question
Following the introduction provided by the screencast, create an m-file that loads in the ASCII battery data file and computes an estimate of the battery’s internal resistance by averaging the values obtained from each measurement. Try to vectorize your code as much as possible.
Name the file battery_resistance_LastName.m.
This is the File
20 8.67380000000000
30 8.78170000000000
40 8.83670000000000
50 8.86970000000000
60 8.89020000000000
70 8.90300000000000
80 8.91600000000000
90 8.92720000000000
100 8.93440000000000
Explanation / Answer
MATLAB CODE:
clc;
clear all;
close all;
load -ASCII battery_data_file.mat
battery_data_file
%Givent that Battery internal resistance is obtained by averaging the values obtained
%from each measurement.
avg_internal_resistance=mean(battery_data_file(:,2))
OUTPUT:
battery_data_file =
20.0000 8.6738
30.0000 8.7817
40.0000 8.8367
50.0000 8.8697
60.0000 8.8902
70.0000 8.9030
80.0000 8.9160
90.0000 8.9272
100.0000 8.9344
avg_internal_resistance =
8.8592