x = linspace(0,4*pi,1000); y = sin(x); z = cos(x); plot3(x,y,z) t = x; x = sin(t); y = cos(t); z = t.^2; plot3(x,y,z) t = linspace(0,10*pi,10000); x = cos(t); y = sin(t); z = t; x = t .* cos(t); y = t.* sin(t); plot3(x,y,z) box on grid on t = linspace(0,10*pi,10); x = t .* cos(t); y = t.* sin(t); z = t; plot3(x,y,z) load ~/Downloads/spectraData masscharge time spectra; whos Name Size Bytes Class Attributes masscharge 4000x22 352000 single spectra 4000x22 352000 single t 1x10 80 double time 4000x22 704000 double x 1x10 80 double y 1x10 80 double z 1x10 80 double plot3(masscharge,time,spectra) [xGrid,yGrid] = meshgrid(0:5,0:5) xGrid = 0 1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 5 yGrid = 0 0 0 0 0 0 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 3 4 4 4 4 4 4 5 5 5 5 5 5 xGrid .* yGrid ans = 0 0 0 0 0 0 0 1 2 3 4 5 0 2 4 6 8 10 0 3 6 9 12 15 0 4 8 12 16 20 0 5 10 15 20 25 [xGrid,yGrid] = meshgrid(1:5,1:5) xGrid = 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 yGrid = 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 xGrid .* yGrid ans = 1 2 3 4 5 2 4 6 8 10 3 6 9 12 15 4 8 12 16 20 5 10 15 20 25 x = -10:.1:10; y = -10:.1:10; [xGrid,yGrid] = meshgrid(x,y); z = xGrid .^ 2 + yGrid .^ 2; mesh(xGrid,yGrid,z) [xGrid,yGrid,zGrid] = meshgrid(0:4,0:4,0:4) xGrid(:,:,1) = 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 xGrid(:,:,2) = 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 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4 5 2 3 4 5 6 3 4 5 6 7 4 5 6 7 8 5 6 7 8 9 sum(:,:,3) = 2 3 4 5 6 3 4 5 6 7 4 5 6 7 8 5 6 7 8 9 6 7 8 9 10 sum(:,:,4) = 3 4 5 6 7 4 5 6 7 8 5 6 7 8 9 6 7 8 9 10 7 8 9 10 11 sum(:,:,5) = 4 5 6 7 8 5 6 7 8 9 6 7 8 9 10 7 8 9 10 11 8 9 10 11 12 indices = find(sum == 4) indices = 5 9 13 17 21 29 33 37 41 53 57 61 77 81 101 [xGrid(indices),yGrid(indices),zGrid(indices)] ans = 0 4 0 1 3 0 2 2 0 3 1 0 4 0 0 0 3 1 1 2 1 2 1 1 3 0 1 0 2 2 1 1 2 2 0 2 0 1 3 1 0 3 0 0 4 combinations = [xGrid(indices),yGrid(indices),zGrid(indices)] combinations = 0 4 0 1 3 0 2 2 0 3 1 0 4 0 0 0 3 1 1 2 1 2 1 1 3 0 1 0 2 2 1 1 2 2 0 2 0 1 3 1 0 3 0 0 4 size(combinations) ans = 15 3 [xGrid,yGrid,zGrid] = meshgrid(0:4,0:4,0:4); sum = xGrid+ yGrid+zGrid; indices = find(sum ==4); combinations = [xGrid(indices),yGrid(indices),zGrid(indices)] combinations = 0 4 0 1 3 0 2 2 0 3 1 0 4 0 0 0 3 1 1 2 1 2 1 1 3 0 1 0 2 2 1 1 2 2 0 2 0 1 3 1 0 3 0 0 4 x = -10:.1:10; y = x; [xGrid,yGrid] = meshgrid(x,y); z = x .^2 + y.^2; surf(x,y,z) {Error using surf (line 57) Z must be a matrix, not a scalar or vector. } surf(xGrid,yGrid,z) {Error using surf (line 57) Z must be a matrix, not a scalar or vector. } z = xGrid .^2 + yGrid .^2; surf(xGrid,yGrid,z) surfc(xGrid,yGrid,z) mesh(xGrid,yGrid,z) meshv(xGrid,yGrid,z) {Undefined function 'meshv' for input arguments of type 'double'. } meshc(xGrid,yGrid,z) surfc(xGrid,yGrid,z) x = -10:1:10; y = x; [xGrid,yGrid] = meshgrid(x,y); z = xGrid .^2 + yGrid .^2; surf(xGrid,yGrid,z) shading(flat) {Undefined function or variable 'flat'. } shading('flat') shading('interp') shading('faceted') x = linspace(-2,2,40); y = linspace(-1,1,40); [xGrid,yGrid] = meshgrid(x,y); z1 = xGrid+yGrid; z2 = xGrid - yGrid; mesh(xGrid,yGrid,z1); hold on mesh(xGrid,yGrid,z2); z = xGrid .^2 + yGrid .^2; figure subplot(2,1,1); surfc(xGrid,yGrid,z); subplot(2,1,2); contour(xGrid,yGrid,z); contourf(xGrid,yGrid,z); contour3(xGrid,yGrid,z); [times,horzPos,vertPos] = Projectile(10,45,.01,3); plot(horzPos,vertPos,'g'); hold on axis([min(horzPos), max(horzPos),min(vertPos),max(vertPos)]) for i = 2: size(horzPos,2) scatter(horzPos(i),vertPos(i),'b'); pause(times(i)-times(i-1)); end hold on hold on