Plotting 2-variable Function with integration using MatLab

3 visualizzazioni (ultimi 30 giorni)
Does anyone have an example of how to plot a 2-variable function with integration in MatLab (without using MuPAD)?
Here is what I've got:
clear all;
%define a, p and w
a=1; p=1; w=5;
%calculate xmin and xmax
xmin=a-p/2 xmax=a+p/2
%define the coordinates
x=linspace(xmin,xmax); y=linspace(0,1);
%define the coordinates along x-y plane
[x,y]=meshgrid(x,y);
%define and compute the given function along the x-y coordinates
z=w-(1/p)*int((x.-y)^2, x, xamin, xmax) ;
figure surf(y,x,z) title ('a=1 and p=1'); xlabel('w') ylabel('t') zlabel('x') axis tight shading interp colorbar
Clearly, there is something wrong with my function z. The function is
z=w-(1/p)*int(x-t)^2dx where x ranges from a-p/2 to a+p/2

Risposte (1)

Youssef  Khmou
Youssef Khmou il 19 Set 2014
The problem is in the function int, it is designed for symbolic calculation while your work with numerical one, if you have the function integral you try the following :
clear all;
a=1; p=1; w=5;
xmin=a-p/2; xmax=a+p/2;
x=linspace(xmin,xmax); y=linspace(0,1);
[x,y]=meshgrid(x,y);
L=integral((x-y)^2,1/length(x));
z=w-(1/p)*(L) ;
figure; surf(x,y,z); title('a=1 and p=1'); xlabel('w');ylabel('t');zlabel('x');
Does the result match your prediction ?

Categorie

Scopri di più su Spline Postprocessing in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by