Cody

# Problem 44260. Multivariate polynomials - convert monomial form to array

Solution 3640153

Submitted on 12 Nov 2020 by cokakola
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
filetext = fileread('coeffArray.m'); assert(~contains(filetext,'regexp'))

2   Pass
exponents = 0; coefficients = randi(1000); cA = coefficients; assert(isequal(coeffArray(exponents,coefficients),cA))

M = 1 V = 1

3   Pass
coefficients = randi(1000,[10 1]); exponents = (9:-1:0)'; cA = coefficients; assert(isequal(coeffArray(exponents,coefficients),cA))

M = 10 V = 1

4   Pass
a = randi(1000); b = randi(1000); exponents = [2 0; 0 1]; coefficients = [a; b]; cA = [0 a; 0 0; b 0]; assert(isequal(coeffArray(exponents,coefficients),cA))

M = 2 V = 2

5   Pass
a = randi(1000); b = randi(1000); c = randi(1000); d = randi(1000); exponents = [2 0 0; 0 2 0; 0 0 2; 0 0 0]; coefficients = [a; b; c; d]; cA = zeros([3 3 3]); cA(1,3,3) = a; cA(3,1,3) = b; cA(3,3,1) = c; cA(3,3,3) = d; assert(isequal(coeffArray(exponents,coefficients),cA))

M = 4 V = 3

6   Pass
coefficients = randi(1000); nVars = randi(20)+1; exponents = ones(1,nVars); cA = zeros(2*ones(1,nVars)); cA(1) = coefficients; assert(isequal(coeffArray(exponents,coefficients),cA))

M = 1 V = 14

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!