Answer to Question #181734 in MatLAB for Iqra Raja

Question #181734

Write MATLAB code to show the result card as shown below. Must ask user to enter the

following fields.


1. Student Name. 2. Reg # 3. Subjects

4. Obtained Marks

Automatically Grading are shown as

Obtained Marks>=80

A

Obtained Marks>=70

B


Obtained Marks>=60

c

Obtained Marks<60

D


1
Expert's answer
2021-04-16T03:49:06-0400
clc
close all;
clear all;




% Enter the dimensions
Mx = 101; % X-grids Number
My = 101; %Y-grids Number
npx = ceil(Mx/2); % Mid-point of x
npy = ceil(My/2); % Mid point of y

Mi = 750; % iterations Number
V = zeros(Mx,My); % Potential matrix
T = 0; % potential (Top_wall)
B = 0; % potential(Bottom_wall)
L = 0; % potential (Left_wall)
R = 0; % potential(Right_wall)


% Initializing_edges_potentials

V(1,:) = L;
V(Mx,:) = R;
V(:,1) = B;
V(:,My) = T;


% Initializing_Corner_potentials

V(1,1) = 0.5*(V(1,2)+V(2,1));
V(Mx,1) = 0.5*(V(Mx-1,1)+V(Mx,2));
V(1,My) = 0.5*(V(1,My-1)+V(2,My));
V(Mx,My) = 0.5*(V(Mx,My-1)+V(Mx-1,My));


length_plate = 51;
lp = floor(length_plate/2);
position_plate = 15;
pp1 = npx+position_plate;
pp2 = npx-position_plate;
for z = 1:Mi % Number of iterations
  
for i=2:Mx-1
for j=2:My-1
  
  
  
V(pp1,npy-lp:npy+lp) = 100;
V(pp2,npy-lp:npy+lp) = -100;
  
V(i,j)=0.25*(V(i+1,j)+V(i-1,j)+V(i,j+1)+V(i,j-1));
end
end
  
end

% Take transpose
V = V';
[Ex,Ey]=gradient(V);
Ex = -Ex;
Ey = -Ey;

% EF Magnitude

E = sqrt(Ex.^2+Ey.^2);
x = (1:Mx)-npx;
y = (1:My)-npy;

% Contour_Display (electric potential)
figure(1)
contour_range_V = -101:0.5:101;
contour(x,y,V,contour_range_V,'linewidth',0.5);
axis([min(x) max(x) min(y) max(y)]);
colorbar('location','eastoutside','fontsize',14);
xlabel('x-axis in meters','fontsize',14);
ylabel('y-axis in meters','fontsize',14);
title('Electric Potential distribution, V(x,y) in volts','fontsize',14);
h1=gca;
set(h1,'fontsize',14);
fh1 = figure(1);
set(fh1, 'color', 'white')

% Contour_Display (EF)
figure(2)
contour_range_E = -20:0.05:20;
contour(x,y,E,contour_range_E,'linewidth',0.5);
axis([min(x) max(x) min(y) max(y)]);
colorbar('location','eastoutside','fontsize',14);
xlabel('x-axis in meters','fontsize',14);
ylabel('y-axis in meters','fontsize',14);
title('Electric field distribution, E (x,y) in V/m','fontsize',14);
h2=gca;
set(h2,'fontsize',14);
fh2 = figure(2);
set(fh2, 'color', 'white')
% Quiver_Display (EFL)
figure(3)
contour(x,y,E,'linewidth',0.5);
hold on, quiver(x,y,Ex,Ey,2)
title('Electric field Lines, E (x,y) in V/m','fontsize',14);
axis([min(x) max(x) min(y) max(y)]);
colorbar('location','eastoutside','fontsize',14);
xlabel('x-axis in meters','fontsize',14);
ylabel('y-axis in meters','fontsize',14);
h3=gca;
set(h3,'fontsize',14);
fr3 = figure(3);
set(fr3, 'color', 'white')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS