Clear Filters
Clear Filters

convert equation to matrix for 3d plot

3 views (last 30 days)
Shane Palmer
Shane Palmer on 11 Jun 2020
Commented: Shane Palmer on 12 Jun 2020
I am trying to represent this function in 3D as a surface, been doing some more experimenting here. I am having problems with turning my P_ave_output into a matrix. It is a bit of a complicated equation and I was hoping matlab had an easy command to do this for me. As I understand it, my R_l and C variables are matrices, and therefore the P_ave_output also needs to be a matrix. I am not quite sure how to do that. The end goal is again to represent a 3d surface plot relating the 3 matrices. Would you have any pointers for this?
I appreciate your help.
clear all
syms omega t R_l s A_in Y C
A_o = 3;
R_c = 40;
L_c = 0.051;
omega_in = 2*pi*f;
A = A_o*sin(omega*t);
%Theta from part a)
theta = 0.244;
%Spring coefficient (N/m)
k = 13660;
%Damping coefficient (N*s/m)
C_d = 0.07;
%Capacitance Assumption
%Impedance equations
Z1 = R_c+R_l+L_c*s+1/(s*C);
Z2 = C_d+k/s+M*s;
%From part a) transfer function
%Output voltage V_l
V_l = (theta*(Y*s)*R_l)/Z1;
%Input excitation force Z_in
%output voltage ratio to input force
Transfer_func = simplify(V_l/A_in);
Transfer_func(s) = vpa(simplify(V_l/A_in),5);
Transfer_func(omega) = subs(Transfer_func, {s},{1j*omega});
amplitude_TF = A_o*abs(Transfer_func(omega_in));
angle_TF = angle(Transfer_func(omega_in));
V_l_steady_state = amplitude_TF*(sin(omega_in*t+angle_TF));
P_ave_output = (amplitude_TF/(sqrt(2)))^2/R_l;
P_ave_diff = diff(P_ave_output);
P_ave_diff = simplify(P_ave_diff, 'Steps',500);
P_ave_max = P_ave_diff == 0;
%R_l_optimal = vpa(abs((solve(P_ave_max, R_l))),3)
%fplot(P_ave_output,[10 200])
%xticks([10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200])
%ylabel('Average Power (Watts)')
%xlabel('Load Resistance R_l (Ohms)')
%Plotmax = vpa(subs(P_ave_output,{R_l},{R_l_optimal}),8)
R_l= [10:10:200];
Star Strider
Star Strider on 11 Jun 2020
In order for the surf call to work, ‘Y’ needs to be defined (or removed). (It’s quadratic in ‘A_in’, so it doesn’t cancel in ‘Transfer_func’.)
It would then be straightforward to calculate ‘ZZ’, and produce the plot.
Shane Palmer
Shane Palmer on 12 Jun 2020
Okay, thank you for the clarification. I'll see if I can include that information in a better way.

Sign in to comment.

Answers (0)


Find more on MATLAB in Help Center and File Exchange


Community Treasure Hunt

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

Start Hunting!