error because "pkg load symbolic"

78 Ansichten (letzte 30 Tage)
Daniel Ball orozco
Daniel Ball orozco am 7 Dez. 2022
Beantwortet: Torsten am 7 Dez. 2022
I try to run this code that my teacher gave me, but I can't because it shows an error on line 2
close all; clear all; clc;
pkg load symbolic
syms w t
A=25;
T=3.5;
f1 = A*(heaviside(t)-heaviside(t-T/3));
f2=(2*A/3)*(heaviside(t-T/3)-heaviside(t-2*T/3));
f3=(A/3)*(heaviside(t-2*T/3)-heaviside(t-T));
f=f1+f2+f3;
% Octave Solution:
Fw(w)=fourier(f)
w0=42;
Fww0=round(eval(Fw(w0))*1000)/1000;
-----------------------------------
I get this error:
Unrecognized function or variable 'pkg'.
Error in www (line 2)
pkg load symbolic

Antworten (2)

Walter Roberson
Walter Roberson am 7 Dez. 2022
That code is not MATLAB code; it is Octave code. For MATLAB comment out
pkg load symbolic
Note:
Fww0=round(eval(Fw(w0))*1000)/1000;
eval() of a symbolic expression tends to fail in MATLAB. Use double(subs(EXPRESSION)) instead of eval(EXPRESSION)

Torsten
Torsten am 7 Dez. 2022
In MATLAB, you don't need to load a package:
pkg load symbolic
This is an octave command.
In MATLAB, either you have a licence for the symbolic toolbox or not. In the first case, your code will run, else not.

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by