Attempt to execute SCRIPT plot as a function?
剛編寫完一個簡單的畫圖程序,代碼如下
close all;
clc;
clear;
% sinx
x = linspace(0,2*pi,200);
f1 = sin(x);
plot(x,f1);
title('plot of f_1=sin(x)');
xlabel('x');
ylabel('f_1');
axis([0 2*pi -1.1 1.1]);
% cos(x)
f2 = cos(x);
figure;
plot(x,f2);
title('plot of f_2 = cos(x)');
xlabel('x');
ylabel('f_2');
axis([0 2*pi -1.1 1.1]);
% plot on the same pic
figure;
plot(x,f1,'-go')
hold on;
plot(x,f2,'-r^');
title('plots of f_1=sin(x),f_2 = cos(x)');
xlabel('x');
ylabel('f_1,f_2');
axis([0 2*pi -1.1 1.1]);
legend('f_1','f_2');
gtext('f_1 = f_2 at two places');
結果我將它保存為plot.m文件了,執行后一直出現?? Attempt to execute SCRIPT plot as a function這個提示,結果仔細查找了下原因是因為文件名取錯了改為plot2D或者其它都可以了,不能用matlab內部自帶的函數名來命名。
總結
以上是生活随笔為你收集整理的Attempt to execute SCRIPT plot as a function?的全部內容,希望文章能夠幫你解決所遇到的問題。