ARIJIT
ARIJIT

Reputation: 5

Matlab cannot plot the 3D graph using "surf" command

Matlab cannot give the 3d surface plot of the following program.Matlab gives the value of all the variables in matrix form. But it cacnot plot the 3d graph using surf command. Why matlab cannot plot a 3d graph using 'surf' command in symbolic variable?? pls help me....

clear all
close all
clc
syms r
c=1;
for R=0.01:0.01:0.03
    R1(c)=R;
    j=1;
    for l=0.3:0.01:0.4
        l1(j)=l;
        A=l*exp(-r^2);
        B=int(A,0,inf);
        B1(c,j)=B;
        j=j+1;
    end
    c=c+1;
end
B1=real(B1)
surf(R1,l1,B1')

Upvotes: 0

Views: 176

Answers (1)

Ander Biguri
Ander Biguri

Reputation: 35525

You just need to add these three lines after the last end:

B1=double(B1)               % Converts from symbolic to numerical
[X ,Y]=meshgrid(R1,l1);     % Creates a grid that is R1,l1 size, repeated
surf(R1,l1,B1')             % plot!

enter image description here

Upvotes: 0

Related Questions