How to convert radian to degree from answer (or equation) generated from syms
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
%%%%%%%%%%%%%%% 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)
m = W/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(vpa(F)) % C1 & C2 are constant and can be determined by BCs
dX = diff(X,t);
conds =[X(0)==x0,dX(0)==v0];
x = dsolve(vpa(F),conds)
%% Plots:
fplot(x,[0 2],'k','LineWidth',1.25);
xlabel('displacment (in m)');
ylabel('time (t)');
title('Displacement Response Curve');
1 commentaire
Walter Roberson
le 2 Mar 2024
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)
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)
%% Plots:
fplot(x,[0 2],'k','LineWidth',1.25);
xlabel('displacment (in m)');
ylabel('time (t)');
title('Displacement Response Curve');
Réponses (1)
Walter Roberson
le 2 Mar 2024
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)
%% 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)))
2 commentaires
Walter Roberson
le 3 Mar 2024
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.
Voir également
Catégories
En savoir plus sur Equation Solving dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!