Question

MATLAB

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Question consists of two subparts. Solved both the subparts Code 1(a): Givern Declare and initialize R R Val-10; DeclarSample Output: -10 10 -5 -5 10 10 Code 1(b): &Given Declare and initialize R R Val-10; Declare and initialize r r Val-1.8; De%Compute y %Compute z Plot 3D graph with yellow color plot3 (x_Val, y_Val, z_Val, y) Hold hold on; Declare and initialize t%Compute z %Plot 3D graph with green color plot 3 (xval, yval, zVal, g) - - - Hold hold on; Declare and initialize t t Valplot3 (x_Val, y_Val, z_Val, b) %Hold hold on; Sample Output: 10 -5 -10 10 10 -5 -5 10 -10

Code to copy

%Code 1.a
%Given
%Declare and initialize R
R_Val=10;

%Declare and initialize r
r_Val=1.8;

%Declare and initialize d
d_Val=0.8;

%Declare and initialize a
a_Val=0.5;

%Declare and initialize steps
steps = 0.1;

%Declare and initialize t
t_Val=0: steps: 200;

%Compute x
x_Val = (((R_Val-r_Val).*cos(t_Val)) + (d_Val.* cos(((R_Val-r_Val)./r_Val).*t_Val)));

%Compute y
y_Val = (((R_Val-r_Val).*sin(t_Val)) + (d_Val.* sin(((R_Val-r_Val)./r_Val).*t_Val))) .* cos(a_Val.*t_Val);

%Compute z
z_Val = (((R_Val-r_Val).*sin(t_Val)) + (d_Val.* sin(((R_Val-r_Val)./r_Val).*t_Val))) .* sin(a_Val.*t_Val);

%Plot 3D graph
plot3(x_Val, y_Val, z_Val)

%Code 1.b
%Given
%Declare and initialize R
R_Val=10;

%Declare and initialize r
r_Val=1.8;

%Declare and initialize d
d_Val=0.8;

%Declare and initialize a
a_Val=0.5;

%Declare and initialize steps
steps = 0.1;

%Declare and initialize t
t_Val = 0: steps: 40;

%Compute x
x_Val = (((R_Val-r_Val).*cos(t_Val)) + (d_Val.* cos(((R_Val-r_Val)./r_Val).*t_Val)));

%Compute y
y_Val = (((R_Val-r_Val).*sin(t_Val)) + (d_Val.* sin(((R_Val-r_Val)./r_Val).*t_Val))) .* cos(a_Val.*t_Val);

%Compute z
z_Val = (((R_Val-r_Val).*sin(t_Val)) + (d_Val.* sin(((R_Val-r_Val)./r_Val).*t_Val))) .* sin(a_Val.*t_Val);

%Plot 3D graph with yellow color
plot3(x_Val, y_Val, z_Val, 'y')

%Hold
hold on;

%Declare and initialize t
t_Val = 40: steps: 80;

%Compute x
x_Val = (((R_Val-r_Val).*cos(t_Val)) + (d_Val.* cos(((R_Val-r_Val)./r_Val).*t_Val)));

%Compute y
y_Val = (((R_Val-r_Val).*sin(t_Val)) + (d_Val.* sin(((R_Val-r_Val)./r_Val).*t_Val))) .* cos(a_Val.*t_Val);

%Compute z
z_Val = (((R_Val-r_Val).*sin(t_Val)) + (d_Val.* sin(((R_Val-r_Val)./r_Val).*t_Val))) .* sin(a_Val.*t_Val);

%Plot 3D graph with red color
plot3(x_Val, y_Val, z_Val, 'r')

%Hold
hold on;

%Declare and initialize t
t_Val = 80: steps: 120;

%Compute x
x_Val = (((R_Val-r_Val).*cos(t_Val)) + (d_Val.* cos(((R_Val-r_Val)./r_Val).*t_Val)));

%Compute y
y_Val = (((R_Val-r_Val).*sin(t_Val)) + (d_Val.* sin(((R_Val-r_Val)./r_Val).*t_Val))) .* cos(a_Val.*t_Val);

%Compute z
z_Val = (((R_Val-r_Val).*sin(t_Val)) + (d_Val.* sin(((R_Val-r_Val)./r_Val).*t_Val))) .* sin(a_Val.*t_Val);

%Plot 3D graph with green color
plot3(x_Val, y_Val, z_Val, 'g')

%Hold
hold on;

%Declare and initialize t
t_Val = 120: steps: 160;

%Compute x
x_Val = (((R_Val-r_Val).*cos(t_Val)) + (d_Val.* cos(((R_Val-r_Val)./r_Val).*t_Val)));

%Compute y
y_Val = (((R_Val-r_Val).*sin(t_Val)) + (d_Val.* sin(((R_Val-r_Val)./r_Val).*t_Val))) .* cos(a_Val.*t_Val);

%Compute z
z_Val = (((R_Val-r_Val).*sin(t_Val)) + (d_Val.* sin(((R_Val-r_Val)./r_Val).*t_Val))) .* sin(a_Val.*t_Val);

%Plot 3D graph with magenta color
plot3(x_Val, y_Val, z_Val, 'm')

%Hold
hold on;

%Declare and initialize t
t_Val = 160: steps: 200;

%Compute x
x_Val = (((R_Val-r_Val).*cos(t_Val)) + (d_Val.* cos(((R_Val-r_Val)./r_Val).*t_Val)));

%Compute y
y_Val = (((R_Val-r_Val).*sin(t_Val)) + (d_Val.* sin(((R_Val-r_Val)./r_Val).*t_Val))) .* cos(a_Val.*t_Val);

%Compute z
z_Val = (((R_Val-r_Val).*sin(t_Val)) + (d_Val.* sin(((R_Val-r_Val)./r_Val).*t_Val))) .* sin(a_Val.*t_Val);

%Plot 3D graph with blue color
plot3(x_Val, y_Val, z_Val, 'b')

%Hold
hold on;

Add a comment
Know the answer?
Add Answer to:
MATLAB ICA 1: a) Using plot3, plot x, y and z given by the follow equations,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT