Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
%%%%%%%%%%%%%%% 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 Commento
Walter Roberson
Walter Roberson il 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)
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');

Accedi per commentare.

Risposte (1)

Walter Roberson
Walter Roberson il 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)
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 Commenti
YQ
YQ il 3 Mar 2024
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 il 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.

Accedi per commentare.

Categorie

Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by