Plot one Variable over another

14 ビュー (過去 30 日間)
Keith Blackstock
Keith Blackstock 2020 年 8 月 19 日
回答済み: Vidhi Agarwal 2024 年 12 月 10 日
clear variables; close all; clc;
phi_dot = 60
aileron = (phi_dot)*0.5;
damp = (100 - aileron)/100;
servo_r = aileron*damp;
servo_l = -aileron*damp;
fplot(servo_l,phi_dot[0,90])
I'm trying to plot the value of "servo_l" for each value of "phi_dot" between 0 and 90.
How should I structure my syntax?
Thanks!
  1 件のコメント
Keith Blackstock
Keith Blackstock 2020 年 8 月 19 日
Just to clarify, I've set phi_dot = 60 as a test number, it bears no real significance.

サインインしてコメントする。

回答 (1 件)

Vidhi Agarwal
Vidhi Agarwal 2024 年 12 月 10 日
I understand you are trying to plot the value of servo_l for each value of phi_dot between 0 and 90. MATLAB's vectorized operations and the "plot' function might be helpful for the same.
Below is the revised code showing how to achieve the same:
clear variables; close all; clc;
% Define the range for phi_dot
phi_dot = 0:1:90; % Create a vector from 0 to 90 with step size 1
% Calculate aileron, damp, and servo_l for each phi_dot
aileron = phi_dot * 0.5;
damp = (100 - aileron) / 100;
servo_l = -aileron .* damp; % Element-wise multiplication
% Plot servo_l against phi_dot
plot(phi_dot, servo_l, 'b-', 'LineWidth', 2);
xlabel('\phi_{dot} (degrees/s)');
ylabel('Servo L');
title('Servo L vs \phi_{dot}');
grid on;
For better understanding of "plot" function, refer to the following documentation:
  • https://www.mathworks.com/help/matlab/ref/plot.html
Hope this helps!

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by