Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab 3D plot using arrays in if/else

  1. Nov 15, 2011 #1
    Dear fellows,

    I am trying to plot a 3D graph, determining the x and y values using an array and the z values using if/else. This is the code I am playing with but I can't get it to work:

    xmin=-1000;
    xmax=1000;
    division=1.0;
    num=((xmax-xmin)/division)+1;

    for i=1:(num/2);
    x(i)=i-(num/2);
    for k=1:(num/2);
    y(k)=k-(num/2);
    for j=1:10:(num/2);
    u(j)=j-num/2;
    v(j)=j+6-num/2;
    if ((x(i)>=u(j))&&(x(i)<=v(j))&&(x(i)<1000)&&(x(i)>0)&&(y(k)>0)&&(y(k)<1000)) |((x(i)>-1000)&&(x(i)<0)&&(y(k)>-1000)&&(y(k)<1000))|((x(i)>0)&&(x(i)<1000)&&(y(k)>-1000)&&(y(k)<0));
    z(i,k)=1.0;
    else
    z(i,k)=0.0;
    end
    end
    end
    end

    surf(x,y,z)

    I am very new to this so any help would be very valuable, thanks!
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: Matlab 3D plot using arrays in if/else
  1. Matlab 3D Scatter Plot (Replies: 4)

  2. 3D plot using Matlab (Replies: 1)

  3. MATLAB, 3D plotting (Replies: 1)

Loading...