Elements Of Electromagnetics
7th Edition
ISBN: 9780190698614
Author: Sadiku, Matthew N. O.
Publisher: Oxford University Press
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
thumb_up100%
Please provide the correct matlab code for the following question.
Expert Solution
arrow_forward
Step 1
Here's a sample MATLAB script that implements the logic you described:
% Read in the three sides of the triangle
a = input('Enter the length of side a: ');
b = input('Enter the length of side b: ');
c = input('Enter the length of side c: ');
% Calculate the semi-perimeter of the triangle
s = (a + b + c) / 2;
% Calculate the area of the triangle
area = (s * (s - a) * (s - b) * (s - c))^(1/2);
% Display the area of the triangle
disp(['The area of the triangle is: ', num2str(area)])
This code prompts the user to enter the length of the three sides of the triangle, calculates the semi-perimeter 's' and the area of the triangle using the equation you provided, and then displays the area in the command window.
Step by stepSolved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, mechanical-engineering and related others by exploring similar questions and additional content below.Similar questions
- I am trying to find a Direction Cosine Matrix (DCM) for the Euler angle body 1-2-3 sequence. I tried making my own function and using the MATLAB function, but the result is a matrix that is transpose of each other. I mean that transpose(EA123toDCM) = E123toDCM. Why is that? Also, for the E123toDCM line, I am using the sequence 'ZYX'. Is that correct or should it be 'XYZ'? I know that that for a DCM of sequence 1-2-3 = R3(theta1)*R2(theta2)*R1(theta3). Is ZYX sequence the same as a 1-2-3 sequence? EA = [pi/3; -pi/4; -pi/6];EA123toDCM = EA123DCM(EA) E123toDCM = angle2dcm(EA(1,1), EA(2,1), EA(3,1), 'ZYX') function [R] = EA123DCM(EA) theta1 = EA(1,1); theta2 = EA(2,1); theta3 = EA(3,1); R1 = @(a)[1 0 0 ; 0 cos(a) -sin(a); 0 sin(a) cos(a)]; R2 = @(a)[cos(a) 0 sin(a) ; 0 1 0 ; -sin(a) 0 cos(a)]; R3 = @(a)[ cos(a) -sin(a) 0; sin(a) cos(a) 0;…arrow_forwardGiven the trasnfer function G(s) numerator and denominator coefficients for Matlab code should be: O s³+2s+1 2s4+2s²+1' the num= [1 0 2 1] and den=[2 020 1] O num=[1 2 1] and den=[2 0 2 1 1] O num=[1 2 1] and den=[2 2 1] O num=[1 0 2 1] and den=[2 2 0 1]arrow_forwardPlease don't provide handwritten solution ......arrow_forward
- MATLAB...Hand written plzzzz asap....FAST PLZZZZZZZZZZZarrow_forwardWrite MATLAB code to perform the following math expression: a) X=7, a=X+2 5 12 2 b) A= 22 L27 4 48 7arrow_forwardI am trying to find a Direction Cosine Matrix (DCM) for the Euler angle body 1-2-3 sequence. I tried making my own function and using the MATLAB function, but the result is matrices that are not equal to each other. But, if I were to use the 'ZYX' sequence, I would get a matrix that is equal to the transpose of the matrix produced by my function.I mean that transpose(EA123toDCM) = E123toDCM if I changed the sequence to 'ZYX'. I never got two equal matrices. Can you fix my code so I would get two equal DCM matrices for the body 1-2-3 sequence? Also, for the E123toDCM line, I am using the sequence 'XYZ'. Is that correct or should it be 'ZYX'? I know that that for a DCM of sequence 1-2-3 = R3(theta1)*R2(theta2)*R1(theta3). Is ZYX sequence the same as a 1-2-3 sequence? EA = [pi/3; -pi/4; -pi/6];EA123toDCM = EA123DCM(EA) E123toDCM = angle2dcm(EA(1,1), EA(2,1), EA(3,1), 'XYZ') function [R] = EA123DCM(EA) theta1 = EA(1,1); theta2 = EA(2,1); theta3 = EA(3,1); R1 =…arrow_forward
- This code keeps on generating graphs with different curves. The picture that you see two different graphs comes from the same code but both of them have different curves. I need the curve to look like the picture that only has one graph. I basically need the line to have a slight curve and every time I run the code it will come up as the same graph every time. Use this code on MATLAB and fix it % Sample data for Diesel and Petrol cars carPosition = linspace(1, 60, 50); % Assumed positions of cars % Use the 'seed' function instead of 'rng' seed = 50; % Define your seed here rand('seed',seed); % Assumed CO2 emissions for Diesel and Petrol CO2Diesel = 25 + 5*cos(carPosition/60*2*pi) + randn(1, 50)*5; % Random data for Diesel CO2Petrol = 20 + 5*sin(carPosition/60*2*pi) + randn(1, 50)*5; % Random data for Petrol % Fit polynomial curves with a reduced degree of 2 pDiesel = polyfit(carPosition, CO2Diesel, 2); pPetrol = polyfit(carPosition, CO2Petrol, 2); % Generate points for best fit…arrow_forward1) Model the following problem with integer programming. The marketing department has been allocated a budget of $10M and would like to determine which products to develop advertising campaigns; note: at most one campaign can be launched for each product. Their goal is to maximize revenue for the company. Data is presented in the table below. Product A BCD E F 10 7 12 8 6 Projected Revenue ($M) Cost ($M) 6 1 2 5 4 3arrow_forwardHello I’m trying to make the graph that you see in the picture, I’m trying the exact copy of that graph using this code but I’m having a hard time doing that. Could you change the code so that it looks like the graph that you see on the picture using MATLAB, please send the code when you are finished. % Sample data for Diesel and Petrol cars carPosition = linspace(1, 60, 50); % Assumed positions of cars % Fix the random seed for reproducibility rng(45); % Assumed positions of cars CO2Diesel = 25 + 5*cos(carPosition/60*2*pi) + randn(1, 50)*5; % Random data for Diesel CO2Petrol = 20 + 5*sin(carPosition/60*2*pi) + randn(1, 50)*5; % Random data for Petrol % Fit polynomial curves pDiesel = polyfit(carPosition, CO2Diesel, 3); pPetrol = polyfit(carPosition, CO2Petrol, 3); % Generate points for best fit lines fitDiesel = polyval(pDiesel, carPosition); fitPetrol = polyval(pPetrol, carPosition); % Plotting the data figure; hold on; scatter(carPosition, CO2Diesel, 'o', 'MarkerEdgeColor', [1 0.5…arrow_forward
- Fix my MATLAB code. % Define unknown quantities in x-y system % abc = Acceleration of B wrt C on beam CD in i direction % vbc = Velocity of B wrt C on beam CD in i direction % xacd = Angular acceleration of beam CD in k direction % xvcd = Angular velocity of beam CD in k direction syms abc vbc xacd xvcd; % Create Unit Vectors in x-y coordinates i = [1,0,0]; j = [0,1,0]; k = [0,0,1]; % Create Unit Vectors in X-Y coordinates (R is rotation Matrix) Theta = 150; % Angle from X-axis to x-axis R = [[cosd(Theta),-sind(Theta), 0]; ... [sind(Theta), cosd(Theta), 0]; [0, 0, 1]]; XYZ = R*[i;j;k]; I = XYZ(1,:); J = XYZ(2,:); K = XYZ(3,:); % Set known quantities for Beam AB (no slider connection). xVab = -2.5*K; % Angular Velocity of Beam AB xAab = -3*K; % Angular Acceleration of Beam AB Rba = 0.2*(cosd(135)*I + sind(135)*J ); % Vector from A to B in X-Y % Calculate velocity and acceleration of point B % due to rotation of Beam AB (no slider connection). Vb1 = cross(xVab,Rba); Ab1 =…arrow_forwardHelp me solve this using MATLABarrow_forwardMatlab code pleasearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Elements Of ElectromagneticsMechanical EngineeringISBN:9780190698614Author:Sadiku, Matthew N. O.Publisher:Oxford University PressMechanics of Materials (10th Edition)Mechanical EngineeringISBN:9780134319650Author:Russell C. HibbelerPublisher:PEARSONThermodynamics: An Engineering ApproachMechanical EngineeringISBN:9781259822674Author:Yunus A. Cengel Dr., Michael A. BolesPublisher:McGraw-Hill Education
- Control Systems EngineeringMechanical EngineeringISBN:9781118170519Author:Norman S. NisePublisher:WILEYMechanics of Materials (MindTap Course List)Mechanical EngineeringISBN:9781337093347Author:Barry J. Goodno, James M. GerePublisher:Cengage LearningEngineering Mechanics: StaticsMechanical EngineeringISBN:9781118807330Author:James L. Meriam, L. G. Kraige, J. N. BoltonPublisher:WILEY
Elements Of Electromagnetics
Mechanical Engineering
ISBN:9780190698614
Author:Sadiku, Matthew N. O.
Publisher:Oxford University Press
Mechanics of Materials (10th Edition)
Mechanical Engineering
ISBN:9780134319650
Author:Russell C. Hibbeler
Publisher:PEARSON
Thermodynamics: An Engineering Approach
Mechanical Engineering
ISBN:9781259822674
Author:Yunus A. Cengel Dr., Michael A. Boles
Publisher:McGraw-Hill Education
Control Systems Engineering
Mechanical Engineering
ISBN:9781118170519
Author:Norman S. Nise
Publisher:WILEY
Mechanics of Materials (MindTap Course List)
Mechanical Engineering
ISBN:9781337093347
Author:Barry J. Goodno, James M. Gere
Publisher:Cengage Learning
Engineering Mechanics: Statics
Mechanical Engineering
ISBN:9781118807330
Author:James L. Meriam, L. G. Kraige, J. N. Bolton
Publisher:WILEY