3D Z number as the same as input value?

>>X= [1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5] <-enter
>>Y=[1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5] <-enter
>>z =[152 89 100 100 100
103 0 100 100 100
89 13 100 100 100
115 100 187 200 111
100 85 111 97 48] <-enter
>> [x,y]=meshgrid(1:.5:5,1:.5:5);
>> z=peaks(x,y);
>> surf(x,y,z)
Is there any other way to represent z number exactly whatever I input? because i just want to show 3d graph from non-continues points.

 Accepted Answer

x= [1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5]
y=[1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 5 5 5 5 5]
z =[152 89 100 100 100 103 0 100 100 100 89 13 100 100 100 115 100 187 200 111 100 85 111 97 48]
X=reshape(x,[],5);
Y=reshape(y,[],5);
Z=reshape(z,[],5);
surf(X,Y,Z)

4 Comments

My Question is that discontinued point shows in 3D graph. But the your method saying that ??? Undefined function or variable 'x'. at the end.. there is other ways to show individuals points of Cartesian coord..
Try
stem3(X,Y,z)
%or
plot3(X,Y,z,'or')
Thanks you. one more thing to do,, Do you know how to interplorate between points? so look like in graph.. surf(x,y,z) --but I don't need to use surf..though. your plot3 method is find just want to show interpolating stacks.
Interpolating would not make sense for non-continuous points.

Sign in to comment.

More Answers (1)

scatter3(X(:), Y(:), z(:))

7 Comments

Hey.. you may know a way of interplorating next to each other. So,, look like surf(x,y,z) but it still remains z value I input.
I mean I tried more data and do scatter3.. but it doesn't work as much as the previous one..
x=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19]
y=[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19]
z=[0 0 0 0 0 0 0 0 0 0 0 0 39 0 0 0 0 0 0 0 0 0 0 0 0 156 163 177 151 136 104 96 85 117 255 252 121 0 0 0 0 0 170 177 204 220 231 237 238 219 191 121 251 178 205 221 177 0 0 0 0 180 145 148 177 211 235 245 245 246 251 190 207 219 231 240 0 0 0 0 206 179 166 182 210 227 241 246 250 245 247 245 246 242 252 0 0 187 187 175 178 184 195 201 201 215 214 222 251 253 253 252 251 255 73 79 67 60 66 93 86 98 105 114 139 163 174 234 247 251 252 250 254 0 0 74 100 91 71 64 86 82 96 129 151 184 187 209 231 241 252 253 0 0 0 0 81 128 157 198 213 217 227 230 232 203 210 230 243 253 245 0 0 0 0 62 59 50 73 117 161 189 195 192 229 225 232 241 238 206 0 0 0 69 65 66 79 100 0 140 129 150 191 198 209 233 228 200 112 0 0 0 89 86 98 109 121 120 107 106 147 191 205 219 223 197 90 20 0 0 0 0 0 0 65 82 76 72 104 154 192 211 217 198 102 26 14 0 0 0 0 0 65 69 62 46 67 109 164 197 206 195 139 34 10 16 0 0 0 0 0 0 0 0 46 73 111 164 195 187 134 34 10 10 0 0 0 0 0 0 0 0 0 49 72 106 163 183 141 36 30 22 0 0 0 0 0 0 0 0 0 0 49 74 105 140 116 30 28 0 0 0 0 0 0 0 0 0 0 0 0 46 73 100 94 37 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 71 71 25 0 0 0 0 0 0 0]
>> scatter3(X(:), Y(:), z(:)) ??? Error using ==> scatter3 at 63 X, Y and Z must be vectors of the same length.
Why is that error?
Your x is 380 entries long, but your y and z are 361 entries long. That is 20*19 compared to 19*19
don'know, just copying from excel column, in oder to avoid #entries, had a color of same size. but still showing :
scatter3(X(:), Y(:), z(:))
??? Undefined variable X.
I will try in different way: add up entries one by one :$
MATLAB is case sensitive. Watch out for x compared to X .
Oh ! I see :) thanks
For reference, this answer was previously listed as accepted due to a bug in MATLAB Answers. Debbie accepted Azzi's answer first, so I left it as the accepted answer. However, Walter does keep the reputation points earned for an accepted answer.

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!