Hi! I'm trying to Create a displacement diagram showing x versus y and z versus y if 2.5≦y≦3.5 with an increment of 0.1.
The derived equation is: 2sin(z)+x*cos(z)= -y
Note that z, x, and y are just arbitrary variables
The problem I have is that the only changing variable is y.
I am a little stuck here, please help.

3 commentaires

Star Strider
Star Strider le 9 Nov 2014
Care to expand on that a bit? Are x, y, and z vectors or scalars? Can you give an illustration of how x, y, and z relate?
See documentation for
surface(X,Y,Z)
Pablo Cardenas
Pablo Cardenas le 9 Nov 2014
they are vectors. z= Omega, x=r1, y= r2

Connectez-vous pour commenter.

Réponses (2)

TED MOSBY
TED MOSBY le 13 Nov 2024
Modifié(e) : TED MOSBY le 18 Nov 2024

0 votes

To create a displacement diagram with the given equation 2(sin(z)) + x(cos(z) = -y), we'll need to express (x) and (z) in terms of (y), given the range (2.5 <= y <= 3.5) with an increment of 0.1. Since (x) and (z) are arbitrary, we can choose different values for them to illustrate the displacement diagram.
% Constants
x = 1; % Arbitrary constant value for x
z = pi / 4; % 45 degrees in radians
% Range for y
y_values = 2.5:0.1:3.5;
% Initialize arrays to store x and z values
x_values = zeros(size(y_values));
z_values = zeros(size(y_values));
% Calculate corresponding x and z values
for i = 1:length(y_values)
y = y_values(i);
% Calculate x based on the equation
x_values(i) = - (2 * sin(z) + y) / cos(z);
% z remains constant in this example
z_values(i) = z;
end
% Plot x vs y
figure;
subplot(1, 2, 1);
plot(y_values, x_values, '-o');
title('x vs y');
xlabel('y');
ylabel('x');
% Plot z vs y
subplot(1, 2, 2);
plot(y_values, z_values, '-o');
title('z vs y');
xlabel('y');
ylabel('z');
% Adjust layout
set(gcf, 'Position', [100, 100, 1000, 400]);
Similarly, you can keep x as constant and calculate z accordingly.
Hope this helps!
x = linspace(-10,10);
z = linspace(-10,10);
y = -(2.*sin(z)+x.*cos(z));
plot3(x, y, z)
xlabel('x'); ylabel('y'); zlabel('z')

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by