Addition and plot of such vectors (each vector has magnitude and angle)
% Program to add vectors
clear;
m = input('How many vectors ? ');
mag(1) = 0;
ang(1) = 0;
for i=1:m;
mag(i+1) = input('Enter magnitude of vector ');
ang(i+1) = input('Enter angle of vector ');
end
n=length(mag);
xcomp = mag .* cos(ang * pi/180);
ycomp = mag .* sin(ang * pi/180);
hold on;
grid;
for i = 1:n;
xvect = [0 xcomp(i)];
yvect = [0 ycomp(i)];
plot(xvect,yvect);
end;
xplt(1) = 0;
yplt(1) = 0;
for i=2:n;
xplt(i) = xplt(i-1)+xcomp(i);
yplt(i) = yplt(i-1)+ycomp(i);
hold off;
figure;
plot(xplt,yplt,'y');
xsum = sum(xcomp);
ysum = sum(ycomp);
xres = [0 xsum];
yres = [0 ysum];
plot(xres,yres,'r');
res = sqrt(xsum^2 + ysum^2);
disp ('Resultant magnitude = ');
disp (res);
resang =180* (atan (ysum/xsum))/pi;
if sign(xsum) == -1;
ansang = 180 + resang;
elseif sign(ysum)== -1 ;
ansang = 360 + resang;
else
ansang = resang;
disp ('Resultant angle = ');
disp (ansang);
Great thanks dear Dr. Behrouz, I appreciate your help.
you can use quiver for plotting 2d vectors (you can get x and y from magnitude and angle as r.cos(a) and r.sin(a)
Some time some universities need to contract with some professors to perform a course in about one-week time ..
04 May 2015 5,903 0 View
Simulation of multi-bus power systems with the ability of FACTS devices inclusion.
31 December 2014 2,784 18 View
Dimensions of the problem, reasons, effects, and steps of a corrective action
11 December 2014 7,370 1 View
Does a one year difference in the age affects success of learning? .. Is it expected to obtain the same outcomes when students enroll university when their age is 17 instead of 18 for example?
10 November 2014 1,205 0 View
Effects of the distributed generation on voltage stability .. Effects of their size, type, location, and mode of control on voltage stability.
10 November 2014 8,314 1 View
Measuring voltage angle of a terminal (point) in an electrical circuit.
10 November 2014 1,097 6 View
Where does the energy of sound go?
10 November 2014 9,787 7 View
Is there a MATLAB/SIMULINK block, or how can one build one?
09 October 2014 10,026 7 View
Simulation can replace experimental work, provided that the modelling is perfect. Do you agree?
09 October 2014 3,911 4 View
In terms of accuracy, and training requirement for different operating conditions.
09 October 2014 9,605 5 View
I would like to understand potential safety concerns while handling SEB in the lab. Especially while working in animal house facility. Would like to know precautions for handling. Sigma MSDS...
07 August 2024 6,034 3 View
During low-temperature testing, new diffraction peaks that appear could be indicative of several phenomena. In one of our tests, we observed notable new peaks around 40° and 45° in a specific...
06 August 2024 726 3 View
I am new to Micromechanics and having similar problem with understanding the implementation of the formula's. I would appreciate if anyone can guide me on how to go about getting a scalar value...
30 July 2024 969 0 View
Some Staphylococcus aureus strains Inhibit the growth of Mycobacteria in Mueller Hinton Agar medium containing 10% OADC. Do some Staphylococcus aureus strains have in vitro antimycobacterial activity?
29 July 2024 10,023 2 View
Please, what is the memory consumption of the Matlab function quad tree decomposition procedure [S = qtdecomp(I)] with respect to the input set I?
27 July 2024 5,455 2 View
all math can be traversed by code? all math can be translate to code?
26 July 2024 9,530 0 View
Hello, I am a research scholar currently working on a project involving image segmentation, and I am interested in using differential evolution for this purpose . I would greatly appreciate it if...
25 July 2024 9,926 1 View
Hello!!! I want to implement the Swerling characteristics functions (CF) directly in MATLAB without using its Fourier integral pairs...the Swerling CFs are actually Laplace Transform of the signal...
23 July 2024 4,925 1 View
Hello, colleagues! There is commenting open for new upcoming edition of USP 1033. Validation target acceptance criteria is now different from what it used to be and it doesn't include Cpm....
23 July 2024 7,292 3 View
Currently I need to calculate detection probabilities (PD) from radar cross section (RCS) data. Beta distribution parameters for this RCS data are calculated and will be used in Swerling0...
22 July 2024 868 0 View