フィルターのクリア

How do I plot a line graph from scatter plot?

1 回表示 (過去 30 日間)
donghun lee
donghun lee 2020 年 3 月 24 日
コメント済み: donghun lee 2020 年 3 月 24 日
clc
clear all
A = 0.05;
l_r = 2; %Wave length of the road
v = 45; %Speed(m/s)
P = l_r/v; %Period
%Om = 1/P*2*pi; %Forcing Frequency
%Om = %0.07m,2m,45m/s
k_l = 26400; %Linear stiffness
m = 483; %Mass
d = -0.1; %Stretching condition
l = 0.5; %Length of the spring
k_s = -(k_l*(l-d))/(4*d); %Spring stiffness
f_n = sqrt(k_l/m)/(2*pi); %Natural frequency
%%
fig = figure();
ax = axes();
hold(ax);
% view([-53 33]);
grid on
Om_array = linspace(0,100,200); %Excitation Amplitude
T = 10;
x0 = [0,0];
for i=1:numel(Om_array)
Om = Om_array(i);
f = @(t,x) [ x(2); ...
-(4*k_s*(x(1)-A*sin(Om*t))*(sqrt((l-d)^2 + (x(1)-A*sin(Om*t))^2) - l))/ ...
(m*(sqrt((l-d)^2 + (x(1)-A*sin(Om*t))^2))) ];
[t, x] = ode45(f,[0,T],x0);
Response_amp = max(x(:,1)) - min(x(:,1));
plot(Om, Response_amp, '.');
end
Hi, all.
If I run this code, I get a scatter plot, but I wish to generate a line graph. Thank you for your time.

採用された回答

KSSV
KSSV 2020 年 3 月 24 日
clc
clear all
A = 0.05;
l_r = 2; %Wave length of the road
v = 45; %Speed(m/s)
P = l_r/v; %Period
%Om = 1/P*2*pi; %Forcing Frequency
%Om = %0.07m,2m,45m/s
k_l = 26400; %Linear stiffness
m = 483; %Mass
d = -0.1; %Stretching condition
l = 0.5; %Length of the spring
k_s = -(k_l*(l-d))/(4*d); %Spring stiffness
f_n = sqrt(k_l/m)/(2*pi); %Natural frequency
%%
fig = figure();
ax = axes();
hold(ax);
% view([-53 33]);
grid on
Om_array = linspace(0,100,200); %Excitation Amplitude
T = 10;
x0 = [0,0];
xval = zeros([],1) ;
yval = zeros([],1) ;
for i=1:numel(Om_array)
Om = Om_array(i);
f = @(t,x) [ x(2); ...
-(4*k_s*(x(1)-A*sin(Om*t))*(sqrt((l-d)^2 + (x(1)-A*sin(Om*t))^2) - l))/ ...
(m*(sqrt((l-d)^2 + (x(1)-A*sin(Om*t))^2))) ];
[t, x] = ode45(f,[0,T],x0);
Response_amp = max(x(:,1)) - min(x(:,1));
xval(i) = Om ;
yval(i) = Response_amp ;
% plot(Om, Response_amp, '.');
end
plot(xval,yval) ;
  1 件のコメント
donghun lee
donghun lee 2020 年 3 月 24 日
thank you so much sir! this is perfect!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Identification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by