One program is not running after differentiation

1 view (last 30 days)
Locate the problem and suggest for correction:
clear all; clc;
%%%%% parameter declaration %%%
g1 = 10^(-4);
g2 = 6;
g3 = 0.66;
g4 = 0.08;
dp = 0;
dc = 0;
d3 = 0;
d4 = 0;
rv = 2.5;
r1 = 12;
k02 = 200;
k04 = 0.01*k02;
c = 1;
% Main Part %
syms om rc real
f1 = om + dp - dc + 1i*g1;
f2 = om + dp + 1i*g2;
f3 = om + dp + d3 + 1i*g3;
f4 = om + dp + d3 + d4 + 1i*g4;
M = (f1*f2 - rc^2)*(f3*f4 - rv^2) - f1*f4*r1^2;
Fp = -((f3*f4 - rv^2)*f1*k02)/M;
Fm = -((M + (f1*f2 - rc^2)*rv^2)*k04)/(M*f4);
G = (f1^2*r1^2*rv^2*k02*k04)/M^2;
kp = (om/c) + 0.5*(Fp + Fm) + sqrt((0.5*(Fp + Fm))^2 + G);
% Define Grn as a function of rc by differentiating kp w.r.t. only om (not by rc) and putting om = 3
Grn = @(rc) double((1/c)*(real(diff(subs(kp, om, 3), om))));
% Define range of rc values
rc_values = linspace(0, 10, 100);
% Evaluate Grn for each rc value
Grn_values = arrayfun(Grn, rc_values);
% Plot Grn versus rc
plot(rc_values, Grn_values, 'LineWidth', 1.5, 'Color', 'r');
xlabel('rc');
ylabel('Grn');
title('Grn versus rc');

Answers (1)

Torsten
Torsten on 2 Apr 2024
Edited: Torsten on 2 Apr 2024
clear all; clc;
%%%%% parameter declaration %%%
g1 = 10^(-4);
g2 = 6;
g3 = 0.66;
g4 = 0.08;
dp = 0;
dc = 0;
d3 = 0;
d4 = 0;
rv = 2.5;
r1 = 12;
k02 = 200;
k04 = 0.01*k02;
c = 1;
% Main Part %
syms om rc real
f1 = om + dp - dc + 1i*g1;
f2 = om + dp + 1i*g2;
f3 = om + dp + d3 + 1i*g3;
f4 = om + dp + d3 + d4 + 1i*g4;
M = (f1*f2 - rc^2)*(f3*f4 - rv^2) - f1*f4*r1^2;
Fp = -((f3*f4 - rv^2)*f1*k02)/M;
Fm = -((M + (f1*f2 - rc^2)*rv^2)*k04)/(M*f4);
G = (f1^2*r1^2*rv^2*k02*k04)/M^2;
kp = (om/c) + 0.5*(Fp + Fm) + sqrt((0.5*(Fp + Fm))^2 + G);
% Define Grn as a function of rc by differentiating kp w.r.t. only om (not by rc) and putting om = 3
Grn = 1/c*real(subs(diff(kp,om),om,sym('3')));
fplot(Grn,[0 25],'LineWidth', 1.5, 'Color', 'r');
xlabel('rc')
ylabel('Grn')
title('Grn versus rc')
  2 Comments
Pradipta Panchadhyayee
Pradipta Panchadhyayee on 12 Apr 2024
Moved: Torsten on 12 Apr 2024
Thank you again. It helps me a lot. Please see my other posts where I need help.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!