how to 2d plot simple ?

조회 수: 4 (최근 30일)
Nx mathlab
Nx mathlab 2022년 1월 27일
답변: Amith 2024년 10월 7일
x=deg2rad(17)
tan(x/2) =(1-cos(x))/(sin(x))
  댓글 수: 1
Torsten
Torsten 2022년 1월 27일
You only defined three single values. What are you trying to plot ?

댓글을 달려면 로그인하십시오.

답변 (1개)

Amith
Amith 2024년 10월 7일
Hi Nx Mathlab,
I assume that you would like to plot a 2D graph using the tan(x/2) defination but with a range of angles. If so refer to the code below -
% Define a vector of angles in degrees
angles_deg = 0:1:360; % Angles from 0 to 360 degrees
% Convert the angles to radians
x = deg2rad(angles_deg);
% Calculate the tangent values
tan_x_over_2 = (1 - cos(x)) ./ sin(x);
% Create a figure
figure;
% Plot the data
plot(x, tan_x_over_2);
% Add labels and title
xlabel('Angle (radians)');
ylabel('tan(x/2)');
title('2D Plot of tan(x/2) vs. Angle');
% Display the grid
grid on;
This code will generate angles from 0 to 360 degrees and, using the definition of tan_x_over_2 , it will plot the angles versus the tan(x/2) value on a 2D graph.
Hope this helps!

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by