---------------------------------------------------------------------------------------------------------------
(a) % Code below
function matrx = makeLayered(n)
%
% make a matrix of (2*n-1)x(2*n-1)
matrx = ones(2*n-1,2*n-1);
if( n > 1)
% recursively call makeLayered(n-1)
mat = makeLayered(n-1);
% fill the first row, last row, first column and last column
% with n
for i=1:2*n-1
matrx(1,i) = n;
matrx(i,1) = n;
matrx(2*n-1,i) = n;
matrx(i,2*n-1) = n;
end
for i=2:2*n-2
for j=2:2*n-2
matrx(i,j) = mat(i-1,j-1);
end
end
end
end
---------------------------------------------------------------------------------------------------------------
(b) Screenshots of test cases :-
(i) For n = 1
(ii) For n = 3
(iii) For n = 8
---------------------------------------------------------------------------------------------------------------
Question 9 Problem Solving, Design, Implementation and Testing in MATLAB (a) Create a function called makeLayered t...
Special Problem: Automated Factorial Create a MATLAB function called xfact that uses a loop to calculate the factorial of an integer. Your function should take a single integer input. Your function should compute the factorials of every integer from 1 to the integer provided by the input. Test your function by prompting the user to enter an integer N and, using a loop create an array named X of length N that contains the factorials of the numbers 1 to...
ONLY REQUIRE C
Problem statement: You are to write a program that manages student marks for a class. Student marks are stored as a 2D array. Each row represents the marks of one student. Each column represents one assessment. For example, if we have two students and 3 assessment items with the marks for student1 being (67.6,88.5, 75.4} and student2 being (77.5, 76.2,78.3} our 2D array would look like: 67.6, 38.5,75.4 77.5, 76.2,78.3 You are to write a script/main function...
MATLAB Create a function that provides a definite integration
using Simpson's Rule
Problem Summar This example demonstrates using instructor-provided and randomized inputs to assess a function problem. Custom numerical tolerances are used to assess the output. Simpson's Rule approximates the definite integral of a function f(x) on the interval a,a according to the following formula + f (ati) This approximation is in general more accurate than the trapezoidal rule, which itself is more accurate than the leftright-hand rules. The increased...
Matlab
Question 2. For this problem you have to create a program that defines two vectors of numbers: A and B and uses a for-loop to combine the values of A and B. Note that different parts of the question below specify different orders for combining the elements. To start this exercise start a MATLAB script called q2.m and put, at the top, the vector definition: B [11:20] Question 2a: Problem definition Copy the file q2.m to q2a.m. For this...
Question:Matrix Notation Interpreter (matrix elements to cell
array of formatted character vectors)
Matlab question
Matrix Notation Interpreter (matrix elements to cell array of formatted character vectors) A system of linear algebraic equations can be writen in matrx notation by applying the definizion of matrix multiplication. For example, the linear system Can be writen as or where and x = 2 matrix input ror the variable A and a × T e function command dennes the output variable linearSystem Code has...
matlab
28 pts Question 8 Problem 4. Write the following function. Do NOT hard code using any of the examples. Your function should work for all possible inputs as specified by the problem. Hard coding will result in significant point loss. (B) (28 Points) Function Name: birthday Party Input (2): (char) An Mx 11 array formatted with information about various birthdays (char) An MxN array of names Output (l): (char) A string containing information about the best birthday Function Description:...
please be thorough with
explanations. thank you
Question 2 Consider the implementation we made in class for ArrayList, and its extensions you did in the lab. In this question, we will add two more methods to this class: the insert method and the pop method. For this question, please submit the modified ArrayList class. a) Implement the method insert (self, index, val) that inserts val before index (shifting the elements to make room for val). For example, your implementation should...
Please use Java for this question.
Input Format Format for Custom Testing Input from stdin will be processed as follows and passed to the function In the first line, there is a single integer n. In the second line, there is a single integer m. In the ph of the next n lines there are m space-separated integers denoting the throw of the initial grid. In the next line, there is a single integer k. In the next line,...
Java Programming
Lab 07 coding
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package lab07;
/**
*
* @author ckandjimi
*/
public class Lab07 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int outcome = methodX(5);
System.out.printf("Result from Method X= %d",outcome);
String [] studentNames =
{"Kingston","John","Nangula","Daniela"};
int Test01[]...