0% found this document useful (0 votes)
5 views5 pages

Matlab Ahmed

The document contains MATLAB scripts that explore reserved variables, perform vector operations, conduct statistical analysis on grades, execute matrix operations, and calculate terminal velocity. It displays values of mathematical constants, calculates various functions for a defined vector, analyzes a set of grades for statistical measures, and demonstrates matrix creation and manipulation. Finally, it includes a terminal velocity calculation based on user input for mass and frontal area.

Uploaded by

polmiranosp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Matlab Ahmed

The document contains MATLAB scripts that explore reserved variables, perform vector operations, conduct statistical analysis on grades, execute matrix operations, and calculate terminal velocity. It displays values of mathematical constants, calculates various functions for a defined vector, analyzes a set of grades for statistical measures, and demonstrates matrix creation and manipulation. Finally, it includes a terminal velocity calculation based on user input for mass and frontal area.

Uploaded by

polmiranosp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

% Task 1: Explore MATLAB reserved variables

clc;

clear;

% Displaying values of reserved variables

disp(['Value of pi: ', num2str(pi)]);

disp(['Value of eps: ', num2str(eps)]);

disp(['Value of realmax: ', num2str(realmax)]);

disp(['Value of realmin: ', num2str(realmin)]);

% Display pi in full precision

format long;

disp(['Pi in long format: ', num2str(pi)]);

% Return display to default format

format short;

disp(['Pi in short format: ', num2str(pi)]);


% Task 2: Vector operations and function calculations

clc;

clear;

% Define the vector t

t = linspace(0, 10, 1000);

% Calculate functions

a = 2 + t + t.^2;

b = exp(t) .* (1 + cos(3 * t));

c = cos(t).^2 + sin(t).^2;

d = atan(t);

% Display first 10 values of each function as a sample

disp(['First 10 values of a: ', num2str(a(1:10))]);

disp(['First 10 values of b: ', num2str(b(1:10))]);

disp(['First 10 values of c: ', num2str(c(1:10))]);

disp(['First 10 values of d: ', num2str(d(1:10))]);


% Task 3: Statistical analysis of grades

clc;

clear;

% Define the grades vector

G = [68, 83, 61, 70, 75, 82, 57, 5, 76, 85, 62, 71, 96, 78, 76, 68, 72, 75, 83,
93];

% Sort and determine the number of grades

sortedG = sort(G);

numGrades = length(G);

% Grades greater than 70

gradesAbove70 = G(G > 70);

% Statistical measures

meanG = mean(G);

medianG = median(G);

modeG = mode(G);

stdDevG = std(G);

% Display results

disp(['Sorted Grades: ', num2str(sortedG)]);

disp(['Number of Grades: ', num2str(numGrades)]);

disp(['Grades above 70: ', num2str(gradesAbove70)]);

disp(['Mean: ', num2str(meanG)]);

disp(['Median: ', num2str(medianG)]);


disp(['Mode: ', num2str(modeG)]);

disp(['Standard Deviation: ', num2str(stdDevG)]);

% Task 4: Matrix operations using ones and zeros

clc;

clear;

% Create a 2x4 matrix of zeros

M1 = zeros(2, 4);

% Create a 4x4 matrix of ones and multiply by 1201

M2 = ones(4, 4) * 1201;

% Display matrices

disp('Matrix M1 (2x4 of zeros):');

disp(M1);

disp('Matrix M2 (4x4 of 1201):');

disp(M2);

% Task 5: Terminal velocity calculation

clc;

clear;

% Terminal velocity script

% Name: [Your Name] Section: [Your Section]

% Input parameters
m = input('Enter the mass of the object in kg: ');

A = input('Enter the frontal area of the object in m^2: ');

% Constants

g = 9.8067; % acceleration due to gravity in m/s^2

Cd = 0.5; % drag coefficient

rho = 1.29; % density of air in kg/m^3

% Calculate terminal velocity

Vt = sqrt(2 * m * g / (rho * A * Cd));

% Print result

fprintf('An object with mass %.2f kg and frontal area %.2f m^2, has a
terminal velocity in air of Vt = %.2f m/s.\n', m, A, Vt);

You might also like