Question

USING MATLAB

Create Inner-Product 3.2 The inner-product we will be using in the problem is defined as | p(x)q(x)dx (p(σ), g(α) And of cour

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

MATLAB Script:

close all
clear
clc
format rat

syms x
f = [1 -2 0 0]; % x^3 - 2*x^2
g = [1 0]; % x
disp('Polynomials:')
fprintf('f = '), disp(f)
fprintf('g = '), disp(g)

r = inner_prod(f, g);
fprintf('\nInner Product of f and g ='), disp(r)
n = norm(f);
fprintf('Norm of f = '), disp(n)

% Inner Product
function r = inner_prod(p, q)
poly_prod = conv(p, q); % Multiplying p and q
poly_int = polyint(poly_prod); % Integrate p*q
r = (1/2) * (polyval(poly_int, 1) - polyval(poly_int, -1)); % Evaluate at the limits of integration, 1 and -1
end

% Norm
function n = norm(p)
n = sqrt(inner_prod(p, p));
end

Output:

Command Window Polynomials: f = 1/5 Inner Product of f and g = Norm of f = 2244/2311

Add a comment
Know the answer?
Add Answer to:
USING MATLAB Create Inner-Product 3.2 The inner-product we will be using in the problem is defined...
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
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