error because "pkg load symbolic"

101 visualizzazioni (ultimi 30 giorni)
Daniel Ball orozco
Daniel Ball orozco il 7 Dic 2022
Risposto: Torsten il 7 Dic 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

Risposte (2)

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

Categorie

Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by