How to generate a golden ratio graph in simulink

조회 수: 14 (최근 30일)
Ragavendra Joshi
Ragavendra Joshi 2023년 4월 15일
댓글: Ragavendra Joshi 2023년 4월 23일
I want to generate a golden ratio graph using xy graph block. Can someone help me?
  댓글 수: 2
Sam Chak
Sam Chak 2023년 4월 15일
Can you at least show the golden ratio equation in MATLAB code format for the plotting purposes?
Ragavendra Joshi
Ragavendra Joshi 2023년 4월 16일
I don't have code for the golden ratio, but I do have one for a spiral trajectory. Can you help me to implement this trajectory in Simulink?
% Spiral trajectory parameters
a = 1; % Scale factor
b = 0.2; % Angular frequency
h = 0.1; % Height above the ground
% Time vector
t = 0:0.01:10;
x = a * exp(b*t) .* cos(t);
y = a * exp(b*t) .* sin(t);
theta = atan2(y,x) + h*t;
traj = timeseries([x', y', theta', t'], t');
plot(x,y);
xlabel('X position');
ylabel('Y position');
title('Spiral Trajectory');

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

채택된 답변

Sam Chak
Sam Chak 2023년 4월 16일
편집: Sam Chak 2023년 4월 18일
18 Apr 2023 (Update): Here are the basic blocks in Simulink that you can use to create the Golden Ratio Spiral plot. The simulation time is , the same as shown in the MATLAB code. Max Step size is set to 0.001.
16 Apr 2023: If you are looking to show something like this, then modify the code to plot for a longer arclength.
t = linspace(0, 2*pi, 1000);
% define the Golden Ratio constant
phi = (1 + sqrt(5)) / 2;
% define parametric equations
x = cos(t);
y = sin(t);
x_phi = cos(t) .* exp(phi*t/(2*pi));
y_phi = sin(t) .* exp(phi*t/(2*pi));
% plotting
figure;
plot(x, y, 'Color', '#A7B7F7', 'linewidth', 2);
hold on;
plot(x_phi, y_phi, 'Color', '#3952B2', 'linewidth', 2);
legend('Circle', 'Golden Spiral');
title('Parametric equation of the Golden Ratio');
% other settings
grid on
axis equal;
box off;
  댓글 수: 13
Sam Chak
Sam Chak 2023년 4월 23일
Oh I see. You can '_smoothen_' the plot by running the sim at a smaller step size. Go to the config menu and set the max step size to 0.01 or 1e-3.
Ragavendra Joshi
Ragavendra Joshi 2023년 4월 23일
Thanks a lot!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by