How to integrate functions dependant on heaviside functions.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm trying to integrate the functions powerSquared and innerProduct but nothing seems o work. the following is my code:
clc
clear all
close all
t = linspace(0,4);
y = @(t) heaviside(t)-2*heaviside(t-2)+heaviside(t-4);
x = @(t) (t).*heaviside(t)-2*(t-1).*heaviside(t-1)+2*(t-3).*heaviside(t-3)-(t-4).*heaviside(t-4);
powerSquared = @(x) x.^2;
innerProduct = @(x,y) y.*x;
inner = integral(powerSquared,0,1)
energy = integral(innerProduct,0,1)
c = inner./energy
0 Kommentare
Antworten (1)
Walter Roberson
am 1 Apr. 2018
innerProduct = @(x,y) y.*x is a function of two variables, but you are using integral() with it, which is the integral of a function of 1 variable.
It is confusing that you are using functions named x and y but you are using parameter names x and y.
My guess at what you want:
t = linspace(0,4);
y = @(t) heaviside(t)-2*heaviside(t-2)+heaviside(t-4);
x = @(t) (t).*heaviside(t)-2*(t-1).*heaviside(t-1)+2*(t-3).*heaviside(t-3)-(t-4).*heaviside(t-4);
powerSquared = @(t) x(t).^2;
innerProduct = @(t) y(t).*x(t);
inner = integral(powerSquared,0,1)
energy = integral(innerProduct,0,1)
c = inner./energy
0 Kommentare
Siehe auch
Kategorien
Mehr zu Calculus finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!