Skip to content
ME-705 · MATLAB and R Programming/Important Questions

MATLAB and R Programming (ME-705) - Important Questions

  1. Unit 310 Marks High Priority

    Write a MATLAB function file that accepts an $n \times n$ matrix (which may contain complex entries), extracts its main diagonal as a vector and returns the sum of the diagonal elements. The function should validate input dimensions and handle non-square inputs by returning an error message. Provide the function code and a short explanation of each step.

    Core programming and matrix indexing task; fundamental MATLAB function writing and handling of complex entries.

  2. Unit 37 Marks Medium Priority

    Write a MATLAB script to generate a random complex vector $z$ of length $100$, compute $\sum z$, and plot $\operatorname{real}(z)$ versus $\operatorname{imag}(z)$. Include proper axis labels and a title. Explain the purpose of each command used.

    Data generation, complex numbers and basic plotting in MATLAB; commonly asked practical scripting question.

  3. Unit 37 Marks Medium Priority

    Using R, create a data frame with one numeric column and one factor column. Show how to append a new row to the data frame, and demonstrate how to subset only the rows where the factor has a specified level. Provide the R commands and brief comments explaining each step.

    Fundamental R data frame manipulation: creation, appending rows and subsetting by factor level; essential for data handling questions.

  4. Unit 310 Marks High Priority

    Explain the differences between MATLAB matrices and R data frames. Provide examples (short code snippets in MATLAB and R) showing a scenario where a MATLAB matrix is preferable and a scenario where an R data frame is preferable. Discuss implications for indexing, heterogenous data and common operations.

    Conceptual comparison between core data structures in MATLAB and R with examples; often tested as theory plus short code snippets.

  5. Unit 37 Marks Medium Priority

    Demonstrate plotting in MATLAB: plot the parametric curve $x=\cos(t)$, $y=\sin(2t)$ for $t \in [0,2\pi]$. Label the axes, add a legend and title, and set the plot to have a grid. Provide the script and explain each plotting command.

    Basic plotting task in MATLAB involving parametric curves, axis labeling and legend usage; standard practical question.

  6. Unit 310 Marks Medium Priority

    Write a MATLAB script or function that reads a CSV file containing numeric columns, computes the column-wise mean (ignoring missing values), and writes the resulting vector of means to a new CSV file. Include error handling for non-numeric columns and describe how missing values (NaN) are handled.

    File input/output in MATLAB: reading CSV, performing column-wise computation, and writing results; important for data processing tasks.

  7. Unit 37 Marks Medium Priority

    Explain how to vectorize loops in MATLAB. Convert the following loop into vectorized form and provide both versions:

    for i = 1:n y(i) = x(i)^2 + 3*x(i) + 5; end

    Explain why the vectorized version is more efficient.

    Vectorization is a key MATLAB performance topic; students are often asked to convert loops to vectorized operations.

  8. Unit 310 Marks Medium Priority

    Write an R function that takes two numeric vectors (predictor and response) and fits a linear model using lm(). The function should return the estimated coefficients, residuals and produce a residual versus fitted values plot. Provide the function code and brief explanation of the outputs.

    R statistical modeling and result extraction; creating a function using lm() and producing diagnostic outputs is a typical applied question.

  9. Unit 37 Marks Low Priority

    Describe how to debug MATLAB code using breakpoints and the debugger. Explain how to use the MATLAB profiler to identify performance bottlenecks. Include a short code example where you set a breakpoint and explain what information you inspect while debugging.

    MATLAB debugging and profiling techniques; conceptual question with a short example. Often asked to test practical knowledge of optimization.

  10. Unit 37 Marks Low Priority

    Demonstrate how to use MATLAB structures and cell arrays to store heterogeneous student records (name, ID, marks). Show how to create a structure array for three students and access the marks of the second student. Provide commands and brief explanations.

    Use of MATLAB cell arrays and structures for heterogeneous data storage; practical creation and access operations are commonly tested.

  11. Unit 310 Marks Medium Priority

    Write a MATLAB function that solves the system $Ax=b$ using LU decomposition (you may use MATLAB's lu() to obtain L and U). Compare the solution and computation time with MATLAB's backslash operator ($A\backslash b$) for a random dense matrix of size $500\times 500$. Present the code and a short analysis of results.

    Linear algebra applications in MATLAB: implementing LU decomposition and comparing with built-in solver tests understanding of numerical methods and built-in functions.

  12. Unit 37 Marks Low Priority

    In R, demonstrate how to import data from an Excel file (using readxl or a similar package), identify and handle missing values (e.g., impute or remove), and export the cleaned data to CSV. Provide the R commands and brief explanation of choices for handling missing data.

    Practical R data import/export skills: reading from Excel, handling missing values, and exporting cleaned data; important in data preprocessing contexts.

Go to where you left off?

Quick Add to Notes

Save questions, your own notes and screenshots into notes filed by unit. It takes a free account.

Create free account

Have an account? Log in