One program is not running after differentiation

1 visualización (últimos 30 días)
Pradipta Panchadhyayee
Pradipta Panchadhyayee el 2 de Abr. de 2024
Movida: Torsten el 12 de Abr. de 2024
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');

Respuestas (1)

Torsten
Torsten el 2 de Abr. de 2024
Editada: Torsten el 2 de Abr. de 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 comentarios
Pradipta Panchadhyayee
Pradipta Panchadhyayee el 3 de Abr. de 2024
Thanks. It works.
Pradipta Panchadhyayee
Pradipta Panchadhyayee el 12 de Abr. de 2024
Movida: Torsten el 12 de Abr. de 2024
Thank you again. It helps me a lot. Please see my other posts where I need help.

Iniciar sesión para comentar.

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by