How to convert radian to degree from answer (or equation) generated from syms

5 次查看(过去 30 天)
%%%%%%%%%%%%%%% Equation of Motion: Undamped SDOF System %%%%%%%%%%%%%%%%%%
%%%%%% Example Problem - 2.2 (Dynamics of Structures - Ashok K.Jain %%%%%%%
close all;
clear all;
clc;
%% INPUTs:
E = 2*10^11; % Young's Modulus (in N/m/m)
I = 3*10^-3; % Moment of Inertia (in m^4)
x0 = 0.02; % Initial Displacement (in m)
v0 = 0.01; % Initial Velocity (in m/s)
L = 3; % Length of Column in Frame (m)
W = 4*10^5; % Lumped Weight Supported by Column (N)
%% OUTPUTs:
k = 2*3*E*I/(L^3) % Total Stiffness (in N/m)
k = 1.3333e+08
m = W/9.81 % Lumped Mass (Kg)
m = 4.0775e+04
wn = sqrt(k/m) % Natural Circular Frequency or Angular Frequency (rad/s)
wn = 57.1839
f = wn/(2*pi());% Natural Cyclic Frequency (Hz)
T = 1/f % Fundamental Time-Period (sec)
T = 0.1099
A = sqrt((x0^2) + (v0/wn)^2) % Amplitude (m)
A = 0.0200
vm = A*wn % Maximum Velocity (m/s)
vm = 1.1437
am = vm*wn % Maximum Acceleration (m/s/s)
am = 65.4025
Phi = atand(x0*wn/v0) % Phase Angle (in degree)
Phi = 89.4990
syms X(t)
F = diff(X,t,2) + (wn^2)*X == 0;
x = dsolve(vpa(F)) % C1 & C2 are constant and can be determined by BCs
x = 
dX = diff(X,t);
conds =[X(0)==x0,dX(0)==v0];
x = dsolve(vpa(F),conds)
x = 
%% Plots:
fplot(x,[0 2],'k','LineWidth',1.25);
xlabel('displacment (in m)');
ylabel('time (t)');
title('Displacement Response Curve');
  1 个评论
Walter Roberson
Walter Roberson 2024-3-2
More exactly
Q = @(v) sym(v);
Pi = sym(pi);
%% INPUTs:
E = Q(2)*10^11; % Young's Modulus (in N/m/m)
I = Q(3)*10^-3; % Moment of Inertia (in m^4)
x0 = Q(0.02); % Initial Displacement (in m)
v0 = Q(0.01); % Initial Velocity (in m/s)
L = Q(3); % Length of Column in Frame (m)
W = Q(4)*10^5; % Lumped Weight Supported by Column (N)
%% OUTPUTs:
k = Q(2)*Q(3)*E*I/(L^3) % Total Stiffness (in N/m)
k = 
m = W/Q(9.81) % Lumped Mass (Kg)
m = 
wn = sqrt(k/m) % Natural Circular Frequency or Angular Frequency (rad/s)
wn = 
f = wn/(2*Pi);% Natural Cyclic Frequency (Hz)
T = 1/f % Fundamental Time-Period (sec)
T = 
A = sqrt((x0^2) + (v0/wn)^2) % Amplitude (m)
A = 
vm = A*wn % Maximum Velocity (m/s)
vm = 
am = vm*wn % Maximum Acceleration (m/s/s)
am = 
Phi = atand(x0*wn/v0) % Phase Angle (in degree)
Phi = 
syms X(t)
F = diff(X,t,2) + (wn^2)*X == 0;
x = dsolve(F) % C1 & C2 are constant and can be determined by BCs
x = 
dX = diff(X,t);
conds =[X(0)==x0,dX(0)==v0];
x = dsolve(F,conds)
x = 
%% Plots:
fplot(x,[0 2],'k','LineWidth',1.25);
xlabel('displacment (in m)');
ylabel('time (t)');
title('Displacement Response Curve');

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2024-3-2
Q = @(v) sym(v);
Pi = sym(pi);
%% INPUTs:
E = Q(2)*10^11; % Young's Modulus (in N/m/m)
I = Q(3)*10^-3; % Moment of Inertia (in m^4)
x0 = Q(0.02); % Initial Displacement (in m)
v0 = Q(0.01); % Initial Velocity (in m/s)
L = Q(3); % Length of Column in Frame (m)
W = Q(4)*10^5; % Lumped Weight Supported by Column (N)
%% OUTPUTs:
k = Q(2)*Q(3)*E*I/(L^3); % Total Stiffness (in N/m)
m = W/Q(9.81); % Lumped Mass (Kg)
wn = sqrt(k/m); % Natural Circular Frequency or Angular Frequency (rad/s)
f = wn/(2*Pi);% Natural Cyclic Frequency (Hz)
T = 1/f; % Fundamental Time-Period (sec)
A = sqrt((x0^2) + (v0/wn)^2); % Amplitude (m)
vm = A*wn; % Maximum Velocity (m/s)
am = vm*wn; % Maximum Acceleration (m/s/s)
Phi = atand(x0*wn/v0); % Phase Angle (in degree)
syms X(t)
F = diff(X,t,2) + (wn^2)*X == 0;
x = dsolve(F); % C1 & C2 are constant and can be determined by BCs
dX = diff(X,t);
conds =[X(0)==x0,dX(0)==v0];
x = dsolve(F,conds)
x = 
%% Plots:
fplot(x,[0 2],'k','LineWidth',1.25);
xlabel('displacment (in m)');
ylabel('time (t)');
title('Displacement Response Curve');
syms CosD(t) SinD(t)
xD = mapSymType(mapSymType(x, 'sin', @(V) SinD(vpa(children(V,1)*180/Pi, 15))), 'cos', @(V) CosD(vpa(children(V,1)*180/Pi, 15)))
xD = 
  2 个评论
Parvesh Deepan
Parvesh Deepan 2024-3-3
I've two problems associated with the solution you provided:
P1 - How to plot with the given solution in form of sinD with respect to 't' ?
P2 - How can one find a specific value of xD(t) at a particular time instant 't' ?
Walter Roberson
Walter Roberson 2024-3-3
In order to graph or evaluate xD, you would need to convert it back to x, the sin() and cos() version.
SinD and CosD are here as placeholders, suggestive of the actual operations. If you were to convert them,
XX = mapSymType(mapSymType(xd, 'SinD', @(V) sind(children(V,1))), 'CosD', @(V) cosd(children(V,1)))
then the sind() and cosd() would immediately get evaluated to sin() and cos() times the appropriate conversion factor.
You can either have a placeholder like SinD and CosD that are suggestive of what is to be done but do not actually do anything, or else you can convert back to radians... in which case you might as well stay with radians in the first place.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Equation Solving 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by