error because "pkg load symbolic"

101 visualizaciones (últimos 30 días)
Daniel Ball orozco
Daniel Ball orozco el 7 de Dic. de 2022
Respondida: Torsten el 7 de Dic. de 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

Respuestas (2)

Walter Roberson
Walter Roberson el 7 de Dic. de 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 el 7 de Dic. de 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.

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by