Write a complete Mat lab script that opens the data file cal

Write a complete Mat lab script that opens the data file called mathdata.txt which was previously generated on your computer in part 1. Your program should access the data in the data file and successfully perform the following calculations, printing the results to the screen for the user to see: Add up all seventy data values. Find the largest data value in the data set. Find the smallest data value in the data set. Determine how many data values fall inside of the following data ranges: -10 lessthanorequalto N

Solution

ANS:

clc
clear all
close all
data = load(\'mathdata.txt\');
data_values = data(:,1);
n = lenght(data);
add = 0;
for i=1:n
    add = add + data(i);
end
Lar_value = max(data);
small-value = min(data);

R1=0;   % -10<= N <-5   region R1
R2=0;   % -5 <= N <0   region R2
R3=0;   % 0<= N < 5    region R3
R4=0;   % 5 <= N 10    region R4
for j=1:lenght(data)
    if (data(i)>=(-10)) && ( data(i)<(-5))
     R1 = R1 + 1;
    elseif (data(i)>=(-5)) && ( data(i)<(0))
     R2 = R2 + 1;
    elseif (data(i)>=0) && ( data(i)<5)
     R3 = R3 + 1;
    elseif (data(i)>=5) && ( data(i)<10)
      R4 = R4 + 1;
    else
    end
    
end
R = R1 + R2 + R3 + R4;

no_of_data_values_in_R1_region = R1
no_of_data_values_in_R2_region = R2
no_of_data_values_in_R3_region = R3
no_of_data_values_in_R4_region = R4

% for checking R value should equal to no of data values

 Write a complete Mat lab script that opens the data file called mathdata.txt which was previously generated on your computer in part 1. Your program should acc

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site