MATLAB: Plot by equation.

plotplottingsubplot

I have an equation for ploting;
x=1 to 10 nanometers ;
y=0.5 to 2 nanometers;
and k=1 to 10;(not nanometers it is a multiplication)
the equation is:
f=8.854187817.*(x.*x.*k.^2)/(y.*y);
and i need a plot for all k values from 1 to 10;
plot(f,k); ant this didn t work;

Best Answer

x = linspace(1,10,15);
y = linspace(0.5,2,15);
k = linspace(1,10,15);
[X,Y,K] = meshgrid(x, y, k);
f = 8.854187817.*(X.*X.*K.^2)./(Y.*Y);
However, this is essentially 4D -- three input coordinates and one result. Even if you divide it up by k value, the result would be 3D for each k value, which would make it a bit difficult to plot everything at the same time. What kind of plots were you hoping for?
pointsize = 36;
scatter3(X(:),Y(:),K(:),pointsize,f(:))
or
slice(X,Y,K,f,[],[],k)
Related Question