Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Connor Smith 03 21 2019
- % Discretization Exercise
- % ((2F matlab codes are the worst don't feel bad))
- clc;
- clear;
- [X,Y] = meshgrid(-0.02:0.0002:0.02,-0.02:0.0002:0.02);
- [Ax,Ay] = meshgrid(-0.02:0.0002:0.02,-0.02:0.0002:0.02);
- m_Ax = zeros(length(X(1,:)),length(Y(1,:)));
- m_Ay = zeros(length(X(1,:)),length(Y(1,:)));
- V = zeros(length(X(1,:)),length(Y(1,:)));
- for i = 1:length(X(1,:))
- for j = 1:length(Y(1,:))
- % Check if it falls within the structure
- r = sqrt(X(i,j)^2 + Y(i,j)^2);
- if (r > 0.01) && (r < 0.02)
- theta = atan(Y(i,j)/X(i,j));
- m_Ax(i,j) = 0.02/r * cos(theta);
- m_Ay(i,j) = 0.02/r * sin(theta);
- V(i,j) = 0.02/r;
- end
- end
- end
- figure(1);
- quiver(Ax,Ay,m_Ax,m_Ay);
- figure(2);
- contour(X,Y,V);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement