Info

This question is closed. Reopen it to edit or answer.

I have built a function which depends on two variables; I would like to get a 3dplot to see the behaviour of my function for different values of the two inputs

1 view (last 30 days)
I have built a function which depends on two variables; I would like to get a 3dplot to see the behaviour of my function for different values of the two inputs. In particular, it seems that the mistake is in this line, when the multiplication by "xu" is performed:
xu = [0.00001:(T/n):(T-0.00001)];
[lambda0,lambda1] = meshgrid(0:.1:3, 0:.1:3);
z = 2*(lambda0.*lambda1.*xu.*(T - xu)).^(0.5);
any solution for the problem?

Answers (1)

Walter Roberson
Walter Roberson on 31 Jan 2016
Your lambda0 and lambda1 are 31 x 31 matrices. Your xu is a row vector of length n, which might or might not be 31. What result are you expecting when you multiply a 31 x 31 matrix by a row vector of length n ?
  4 Comments
Stephen23
Stephen23 on 1 Feb 2016
Something like this:
[lambda0,lambda1,XU] = ndgrid(0:.1:3, 0:.1:3, xu);
Z = 2*(lambda0.*lambda1.*XU.*(T - XU)).^(0.5);
Walter Roberson
Walter Roberson on 1 Feb 2016
Right. Notice that really you have a function of 3 variables here, the two lambda and xu, so you will need a 4 dimensional display routine, not a 3d display routine.

Community Treasure Hunt

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

Start Hunting!