polar plot

조회 수: 4 (최근 30일)
Pinco
Pinco 2012년 4월 6일
답변: Sanchari 2024년 7월 25일
Hi everyone! I want to plot a function like that:
the plot is in fig. 138 (c) and its expression in Ms.
What's the code?
because, I think, there is a scale factor, I use this code:
ts=linspace(0,2*pi,500);
Ms = 1-ts.*sin(ts)-0.5*cos(ts);
polar(ts,Ms)
but this generates a wrong plot. How can I do this?
Thanks a lot for your answer! Pinco

답변 (1개)

Sanchari
Sanchari 2024년 7월 25일
Hello Pinco,
The link provided does not work. However, to create a polar plot of the equation provided: [ M_s = 1 - t \sin(t) - 0.5 \cos(t) ], the following code can be used:
% Define the range for the variable t
ts = linspace(0, 2*pi, 500);
% Compute the values of Ms using the given equation
Ms = 1 - ts .* sin(ts) - 0.5 * cos(ts);
% Create the polar plot
figure;
polarplot(ts, Ms);
% Add title and labels
title('Polar Plot of M_s = 1 - t \cdot sin(t) - 0.5 \cdot cos(t)');
Output:
There can be additional customizations like adding grid lines, setting axis limits, or changing the line style and colour. Here's an example with these additional customizations:
% Define the range for the variable t
ts = linspace(0, 2*pi, 500);
% Compute the values of Ms using the given equation
Ms = 1 - ts .* sin(ts) - 0.5 * cos(ts);
% Create the polar plot
figure;
polarplot(ts, Ms, 'r', 'LineWidth', 1.5); % Red color and thicker line
% Add title and labels
title('Polar Plot of M_s = 1 - t \cdot sin(t) - 0.5 \cdot cos(t)');
% Customize the polar plot
ax = gca;
ax.ThetaGrid = 'on'; % Turn on theta grid
ax.RGrid = 'on'; % Turn on radial grid
ax.ThetaTick = 0:45:360; % Set theta tick marks every 45 degrees
ax.RLim = [-2 2]; % Set radial limits (adjust as needed)
Output:
Notes:
  1. Ensure that the function to be plot matches with the one intended.
  2. Adjust the radial limits "ax.RLim" as needed to ensure that the plot is displayed correctly.
  3. Further customizations are possible using properties of "polarplot" and "axes" objects.
Hope this helps!

카테고리

Help CenterFile Exchange에서 Polar Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by