error because "pkg load symbolic"

조회 수: 78 (최근 30일)
Daniel Ball orozco
Daniel Ball orozco 2022년 12월 7일
답변: Torsten 2022년 12월 7일
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

답변 (2개)

Walter Roberson
Walter Roberson 2022년 12월 7일
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 2022년 12월 7일
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.

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by