Wednesday, July 17, 2013

plotting 3D vector field in MATLAB in many different ways

Recently I read post from Dr. Doug Hull's blog:

http://blogs.mathworks.com/videos/2009/10/23/basics-volume-visualization-19-defining-scalar-and-vector-fields/

I liked this video tutorial so much and I really felt that should finish the 'homework' assigned at the very end. So I spent sometime on it and here are my code and figures.

clear;close all;clc;
load wind
speed=sqrt(u.*u+v.*v+w.*w);
%%
figure(1)
scatter3(x(:),y(:),z(:),[],speed(:))
%%
figure(2)
slice(x,y,z,speed,[],[],[5 10 15])
zlim([0 20])
%%
figure(3)
[xs, ys]=meshgrid(60:140, 20:60);
zs=20*ys./xs;
slice(x,y,z,speed,xs,ys,zs)
%%
figure(4)
contourslice(x,y,z,speed,[],[],[5 10 15],20)
zlim([0 20])
view(3)

%%
figure(5)
fv1=isosurface(x,y,z,speed, 10);
fv2=isosurface(x,y,z,speed, 20);
fv3=isosurface(x,y,z,speed, 30);
h1=patch(fv1);
h=patch(fv2);
h3=patch(fv3);
set(h1,'FaceColor',[1, 0.6, 0])
set(h1,'EdgeColor','none')

set(h,'FaceColor',[0, 0.5, 0.5])
set(h,'EdgeColor','none')

set(h3,'FaceColor',[1, 0.4, 1])
set(h3,'EdgeColor','none')
camlight;
lighting gouraud
view(3)

%% 
figure(6)
quiver3(x,y,z,u,v,w);

%%
figure(7)
[cx,cy,cz]=meshgrid([70 80 90 100 110 120], [20 30 40 50 60],[0 5 10 15]);
coneplot(x,y,z,u.*100,v.*100,w.*100,cx,cy,cz,speed);
% set(h, 'edgecolor','none')
shading interp;
view(3)

%%
figure(8)
streamline(x,y,z,u,v,w,80,40,10)
hold on
plot3(80,40,10, 'bo')
view(3)

%%
figure(9)
[sx,sy,sz]=meshgrid(100,[20 30 40], [5 10]);
streamline(x,y,z,u,v,w,sx,sy,sz)
hold on
plot3(sx(:),sy(:),sz(:),'bo')
view(3)

%%
figure(10)
streamslice(x,y,z,u,v,w,[],[],1)
view(3)

%%
figure(11)
streamtube(x,y,z,u,v,w,sx,sy,sz)
shading interp;
view(3)
%%
figure(12)
h=streamribbon(x,y,z,u,v,w,sx,sy,sz);
shading interp;
view(3)


Figure 1

Figure 2

Figure 3

Figure 4

Figure 5

Figure 6

Figure 7

Figure 8

Figure 9

Figure 10

Figure 11

Figure 12



1 comment:

  1. You can get some latest computer tips, blogging tips and internet tips in the blog TechnTechie.

    ReplyDelete

Any comments?

my-alpine and docker-compose.yml

 ``` version: '1' services:     man:       build: .       image: my-alpine:latest   ```  Dockerfile: ``` FROM alpine:latest ENV PYTH...