Question

40 SC Matrix C sym (zeros) C(1,1) = 1; tsets the element 1,1 to be egy 42 - 44 - 45 - 46 - for n = 2:N starts a for loop for

hi which code should I use to get the following matrix and be able to change the number of rows. the code in the picture doesn't work for me for some reason. thank you. I use matlab program

0 0 0 C. pelynomials nko hhh hk² k² Whik hehk v

it needs to look like this and be a 10 by 10 matrix.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

============== matlab code for the given specific problem is ===================

row = input('Enter number of the rows:');%%taking input row
col = input('Enter number of the columns:');%% taking input column
syms h;%% declaring system variable
syms k;%% declaring system variable
mat = sym(zeros);%% initialization of symbolic matrix
for i = 1:row%%iterating each row
for j = 1:col%% iterating each column

powh = i-j;%% calculating power of h
powk = j-1;%% calculating power of k
if powh==0 && powk==0%% if both power is 0 ,1 symbol filled in the table
mat(i,j) = 1;
elseif powh<0 %% h power is negative 0 is filled
mat(i,j) = 0;
elseif powk==0%% k power is 0 ,h power is filled
mat(i,j) = h^powh;
elseif powh==0%% h power is 0 ,k power is filled
mat(i,j) = k^powk;
else %%both power is filled
mat(i,j) = h^powh * k^powk;
end
end
end
disp(mat);%%displaying the matrix.

----------------------------------------------------------------------------------------------------------------------------------

Screenshots of the code:

----------------------------------------------------------------------------------------------------------------------------------

col = input(Enter number of the columns:);%% taking input column syms h;%% declaring system variable syms k; declaring syst>> Untitled2 Enter number of the rows: 4 Enter number of the columns: 4 [ 1, 0, 0, 0] [ h, k, 0, 0] [ h^2, h*k, k^2, 0] [ h^3

==================================end======================================

like the post

Add a comment
Know the answer?
Add Answer to:
hi which code should I use to get the following matrix and be able to change...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • % Bisection.m Lines of code 17-26 and 43-47 are bold % This code finds the root...

    % Bisection.m Lines of code 17-26 and 43-47 are bold % This code finds the root of a function f(x) in the interval [a, b] using the Bisection method % % It uses f.m to define f(x), and assumes f(x) is continuous % It requires specification of a, b and the maximum error % It defines error using |f(xnew)| % Define inputs for problem a=0; %Defines lower limit of initial bracketing interval b=1; %Defines upper limit of initial bracketing interval...

  • How would I be able to get a Merge Sort to run in this code? MY...

    How would I be able to get a Merge Sort to run in this code? MY CODE: #include <iostream> #include <fstream> #include <stdlib.h> #include <stdio.h> #include <time.h> using namespace std; class mergersorter { private:    float array[1000] ;    int n = 1000;    int i=0; public:    void fillArray()    {        for(i=1;i<=n;i++)        {            array[i-1]= ( rand() % ( 1000) )+1;        }    }    void arrayout ()    {   ...

  • Write a function Transpose that transposes a matrix T with M rows and N colums. The...

    Write a function Transpose that transposes a matrix T with M rows and N colums. The transposed matrix, TT, should have N rows and M columns. Example. Given the matrix T. (C++14) Example: 1 2 3 0 -6 7 The transposed matrix TT is 1 0 2 -6 3 7 DEFAULT CODE: Add to code as needed: #include <iostream> #include <string> #include <cmath> using namespace std; void Transpose(int T[100][100], int TT[100][100], int M, int N) { int i; int j;...

  • 2. What is the output of the following code fragment? n = 1; while (n <=...

    2. What is the output of the following code fragment? n = 1; while (n <= 5) { n++; cout << n << ' '; a.1 2 3 4 5 b. 1 2 3 4 c. 1 1 1 forever d. 2 3 4 5 e. 2 3 4 5 6 3. What is the termination condition for the following While loop? while (beta > 0 && beta < 10) { cout << beta << endl; cin >> beta; }...

  • 1. Code a breadth First traversal. 2. Code a depth First traversal. Note, your traversals should return a string listing...

    1. Code a breadth First traversal. 2. Code a depth First traversal. Note, your traversals should return a string listing the nodes added to the min spanning tree and the order they are added. Using Python. Starter code: from collections import deque class Edge: def __init__(self, endIndex, next = None): self.endIndex = endIndex self.next = next class Node: def __init__(self, name): self.name = name self.visited = False self.connects = None class Graph: def __init__(self): self.nodeList = [] self.size = 20...

  • Please do this in Matlab. Not sure if you need this code: e cofunction [x, er,...

    Please do this in Matlab. Not sure if you need this code: e cofunction [x, er, n] = FixedPoint(g, x1, maxtol, maxitr) if nargin < 4, maxitr = 25; end if nargin < 3, maxtol = 1e-3; end k = 0 ;    er = 1; x = x1;    while er >= maxtol && k < maxitr k=k+1; xold = x; x=g(x); er=abs((x-xold)/x); fprintf('iter = %i, x = %e, er = %e ', k,x,er); end n=k; if n ==...

  • I have written my code for an employee management system that stores Employee class objects into...

    I have written my code for an employee management system that stores Employee class objects into a vector, I am getting no errors until I try and compile, I am getting the error: C2679 binary '==': no operator found which takes a right-hand operand of type 'const std::string' (or there is no acceptable conversion). But I am not sure why any help would be great, Thank you! 1 2 3 4 5 6 7 8 9 10 11 12 13...

  • Given a matrix, clockwise-rotate elements in it. Please add code to problem3.cpp and the makefile. I...

    Given a matrix, clockwise-rotate elements in it. Please add code to problem3.cpp and the makefile. I have also given the main_problem3.cpp and problem3.h to test. problem3.cpp::: #include "problem3.h" // A function to rotate a matrix mat[][MAX] void rotatematrix(int m, int n, int mat[][MAX]) { // your code here    } Makefile::: all : problem3.o    g++ -o mainp3 # your code here problem3.o : problem3.h problem3.cpp    # your code here clean:    rm -f *.o mainp3 main_problem3.cpp::: #include <iostream>...

  • Let G- be a generator matrix for a block code (not necessarily a "good" code) a) b) c) What is th...

    Let G- be a generator matrix for a block code (not necessarily a "good" code) a) b) c) What is the n, k, the rate and the bandwidth expansion for this code? Find the parity check matrix H )Build the standard array for the code. Assume the coset leaders are vectors with one "l", starting from the left side of the vector, i.e., the first coset leader will be (1 0...), the second (01 0 ...) starting again from the...

  • C++ language I need to update this code with the following: ask the user for how...

    C++ language I need to update this code with the following: ask the user for how many structures they would like. Once you get the number, allocate an array of pointers. Once they have been created, proceed to loop through and get the data as usual, and display it back to the screen. struct record {    int age;    string name; }; int check(record r[], int n, string nm) {    for (int i = 0; i < n;...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT