0% found this document useful (0 votes)
7 views

Assignment-1

The document outlines a MATLAB assignment focusing on basic syntax, variables, mathematical operations, and matrices. It includes specific tasks such as creating variables, performing calculations, and solving equations, along with guidelines for submission and evaluation criteria. Students are required to submit a script file and a PDF of results, ensuring clarity and proper documentation in their code.

Uploaded by

Sauvik Arya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Assignment-1

The document outlines a MATLAB assignment focusing on basic syntax, variables, mathematical operations, and matrices. It includes specific tasks such as creating variables, performing calculations, and solving equations, along with guidelines for submission and evaluation criteria. Students are required to submit a script file and a PDF of results, ensuring clarity and proper documentation in their code.

Uploaded by

Sauvik Arya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

MATLAB Assignment: Basic Syntax, Variables, Operations, and Matrices

Instructions:

1. Complete all questions in MATLAB and submit your script file (.m file) along with a
PDF of your results.
2. Add comments in your code to explain each step.
3. Ensure proper variable naming and code readability.
4. Where applicable, include output values and visualizations (if any)

Section 1: Basic Syntax and Variables

1. Write a MATLAB script that:


a) Assigns your name and roll number to string variables.
b) Creates three different types of numeric variables: integer, floating-point, and
complex number.
c) Displays these variables using the disp() function.
2. Define a variable radius = 5. Compute and display:
o The area of a circle using πr².
o The circumference of the circle using 2πr.
o Use both predefined constant pi and the format long command to show
precision

Section 2: Mathematical Operations

3. Define two variables, a = 8 and b = 3. Perform and display results for:


o Addition, subtraction, multiplication, division, exponentiation (a^b), and
modulus (mod(a, b)).
o Use printf() to display the results in a formatted manner.
4. Create a variable x = -5:0.5:5. Compute and display:
o The square root of each element in x (use sqrt() but handle negative values).
o The sine and cosine of x values in degrees.

Section 3: Matrices and Matrix Operations

5. Create the following matrices in MATLAB:

Compute and display:

o Matrix addition and subtraction (A + B, A - B).


o Matrix multiplication (A * B).
o Element-wise multiplication (A .* B).
o Transpose of matrix A.
o Determinant of A.
6. Create a 4×4 random matrix using rand().
o Extract and display its second row and third column.
o Replace all elements in the first row with zeros.
7. Solve the system of equations using matrix methods in MATLAB:

3x + 2y - z = 5

2x - y + 3z = 10

x + 4y + 2z = 8

o Define the coefficient matrix C and the result vector d.


o Use the inv() function and the \ operator to solve for [x; y; z].

Submission Guidelines:

 Submit the .m script file with all the answers properly commented.
 Submit a PDF of outputs, including screenshots of matrices and numerical results.
 Ensure that your name and roll number appear as a comment at the top of your script.

Evaluation Criteria:

 Correctness of the MATLAB code (50%)


 Clarity and readability of the script, including comments (20%)
 Proper use of MATLAB functions and syntax (20%)
 Formatting of output and overall presentation (10%)

You might also like