Write a MATLAB code that can convert a vector in any
coordinate system to the other two coordinate
systems. The code must ask the use to select in which coordinate
system is the entered data.
Write a MATLAB code that can convert a vector in any
coordinate system (Cartesian, cylindrical or spherical) to the
other two coordinate
systems. The code must ask the use to select in which coordinate
system is the entered data.
clc;
clear all;
a=1;
while (a==1)
fprintf('Select the co-ordinate system in which you wish to enter
the coordinates\n');
opt=input('Press 1 for catersian co-ordinate system or press 2 for
cylindrical coordinate system or press 3 for spherical coordiante
system: ');
if (opt==1)
x=input('\n Enter the x coordinate: ');
y=input('\n Enter the y coordinate: ');
z=input('\n Enter the z coordinate: ');
rho=sqrt(x^2+y^2);
if (x==0 && y==0)
phi=0;
elseif (x>=0)
phi=asind(y/rho);
elseif (x>0)
phi=atand(y/x);
elseif (x<0)
phi=-asind(y/rho)+pi;
else
end
fprintf ('\n The coordinates in the cylindrical coordinate system:
(%f,%f,%f)',rho,phi,z);
r=sqrt(x^2+y^2+z^2);
theta=acosd(z/r);
phi=atand(y/x);
fprintf('\n The coordinates in the spherical coordinate system:
(%f,%f,%f)',r,theta,phi);
a=input('\n Press 1 to continue or 2 to quit: ');
elseif (opt==2)
rho=input('\n Enter the rho coordinate: ');
phi=input('\n Enter the phi coordinate (in degrees): ');
z=input('\n Enter the z coordinate: ');
x=phi*cosd(phi);
y=phi*sind(phi);
z=z;
fprintf ('\n The coordinates in the cartesian coordinate system:
(%f,%f,%f)',x,y,z);
r=sqrt(x^2+y^2+z^2);
theta=acosd(z/r);
phi=atand(y/x);
fprintf('\n The coordinates in the spherical coordinate system:
(%f,%f,%f)',r,theta,phi);
a=input('\n Press 1 to continue or 2 to quit: ');
elseif (opt==3)
r=input('\n Enter the r coordinate: ');
phi=input('\n Enter the phi coordinate (in degrees): ');
theta=input('\n Enter the theta coordinate (in degrees): ');
x=r*sind(theta)*cosd(phi);
y=r*sind(theta)*sind(phi);
z=r*cosd(theta);
fprintf ('\n The coordinates in the cartesian coordinate system:
(%f,%f,%f)',x,y,z);
r=sqrt(x^2+y^2+z^2);
theta=acosd(z/r);
phi=atand(y/x);
fprintf('\n The coordinates in the spherical coordinate system:
(%f,%f,%f)',r,theta,phi);
a=input('\n Press 1 to continue or 2 to quit: ');
else
warning('Invalid input');
a=input('\n Press 1 to continue or 2 to quit: ');
end
end
Write a MATLAB code that can convert a vector in any coordinate system to the other...
Practice: 1. A vector defined at (4,0,0) is expressed in Cartesian coordinate system as (2,3,0), convert it into cylindrical and spherical representations; 2. If the same vector is moved to (4,0,1), what are its cylindrical and spherical representations?
Matlab code for this problem.
1[35pl Write a user-defined MATLAB function that determines the unit vector in the direction of the line that connects two points (A and B) in space. For the func- tion name and arguments, use n = unitvec (A,B). The input to the function are two vectors A and B, each with the Cartesian coordinates of the corre- sponding point. The output is a vector with the components of the unit vector in the direction from...
please solve in matlab
1[35p) Write a user-defined MATLAB function that determines the unit vector in the direction of the line that connects two points (A and B) in space. For the func- tion name and arguments, use n = unitvec (A,B). The input to the function are two vectors A and B, each with the Cartesian coordinates of the corre- sponding point. The output is a vector with the components of the unit vector Join the direction from A...
2- Write a MATLAB code to visualize (2D) the electric field vector due to four equal point charges Q, Placed at vertices of a rectangle of length a and width w in free space. The code must ask the user to input the value of the charge and the size of the edges.
2- Write a MATLAB code to visualize (2D) the electric field vector due to four equal point charges Q, Placed at vertices of a rectangle of length...
Write a code such that for any given vector with integer components, it finds the elements which are the multiples of both 6 and 9. in matlab
help me
Problem: Write a simple C program that calculates the corresponding y-coordinate for any x-coordinate onaline defined by two points. These points areinputspecifiedas pairsofxandycoordinates in the two-dimensional Cartesian coordinate system. Youneed to determine the slope ofthe line and they-intercept for the line plotted by these two points and store this data in memory. The programmustpromptthe userforthe coordinates of the first point X1 and then Y1, and then prompt the user for the second point, X2 and then Y2. After...
9. Using Generalized Curvilinear Coördinates, if the scalar S and the vector Ä are both functions of position, prove the following relations: (a) 7 (SA)=s(8. A)+A.IS; (b) (x(SA)=s(0xĂ)+()xA; (c) Ex(s)=0; (a) 8x(0xA)=(. A)-VA. Most of these identities are independent of the specific coördinate system that one employs; however, care must be taken with the operator VA, since in Cartesian Coördinates, it is defined as G?A=i(v?4)+1(v24,)+R(v?4.), but in the Cartesian case, the unit vectors are independent of the coordinate variables, which...
Assume that y is a column vector with ten elements, write matlab code that will create a stem plot of the vector starting at a horizontal axis value of 1. Add code that will create the stem plot of the vector starting at a horizontal axis value of 0. Create additional code that creates a stem plot but plots y at every other horizontal value (i.e., 0, 2, 4, etc)
*MATLAB CODE* 3)Write a function 'mydsort' that sorts a vector in descending order (using a loop, not the built-in sort function). 4)write a function that will receive a vector and will return two index vectors: one for ascending order and one for descending order. Check the function by writing a script that will call the function and then use the index vectors to print the original vector in ascending and descending order. **Please make sure they work. I have found...
Write a MATLAB script named Converter.m and MATLAB two functions, each in its own script, named D2BConverter.m and B2DConverter.m The Selection Output should be the following: Binary to Decimal & Decimal to Binary Converter Please Select: 1. Convert from Decimal To Binary 2. Convert from Binary To Decimal 3. Exit If user select option [1] then you ask the user to enter a decimal number (whole number) and display the equivalent binary, else if the user select option [2] then...