# Find the meaning of each line of code

9 Ansichten (letzte 30 Tage)
surendra agrawal am 21 Jun. 2021
Bearbeitet: Image Analyst am 24 Jun. 2021
clearvars
clc
syms y(t) s Y Dy(t)
C = input('Enter the coeff. of D2y, Dy and y as an array: ');
F = input('Enter the non-homogeneous part f(t): ');
IC = input('Enter the initial conditions [y0 Dy0]: ');
DEq = C(1)*diff(y,2)+C(2)*diff(y,1)+C(3)*y -F;
LDEq = laplace(DEq);
LDEq1 = subs(LDEq,{laplace(y(t),t,s),y(0),subs(diff(y(t), t), t, 0)},{Y, IC(1),IC(2)});
Ys = solve(LDEq1,Y);
y = collect(simplify(ilaplace(Ys)));
disp('The solution of the given DE is: ');
disp(char(y))
fplot(y)
title('Plot of the Solution')
##### 2 KommentareKeine anzeigenKeine ausblenden
KSSV am 21 Jun. 2021
Read the respective function's documentation you will get it.
Walter Roberson am 21 Jun. 2021
I have a personal policy not to give explanation of the code in situations such as this.
When someone asks to have ever line explained, but does not give any specific questions or discuss the concepts involved, then we as volunteers have to assume that the person doing the asking might not have any computing experience at all, and might not have even know things like "positional notation"... let alone have any experience with the topic (such as differential equations.)

Melden Sie sich an, um zu kommentieren.

### Antworten (2)

Divija Aleti am 24 Jun. 2021
Hi Surendra,
As KSSV mentioned, do read the documentation of each function used in the code. It will be self-explanatory.
Hope this helps!
Regards,
Divija
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Image Analyst am 24 Jun. 2021
Bearbeitet: Image Analyst am 24 Jun. 2021
Since you didn't write it yourself, I'd contact the author and ask them why they wrote such poor code with no comments and variable names that are not descriptive at all. It's an alphabet soup mess of a program. Ask the author to write like a professional programmer and correct it so that it's virtually self-documenting. It's their fault, not yours, and they should fix it. I train our programmers not to write bad code like that.
See Loren's blog
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Calculus finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by