Calling a function in MATLAB
이전 댓글 표시
How can I call a function written in an .m file?
채택된 답변
추가 답변 (1개)
Aicha Ibtissem
2024년 1월 19일
편집: Walter Roberson
2024년 1월 19일
Hello, I cant call my function, I have this error.THANKS
Error<<Execution of script myplotfunction1 as a function is not supported:
C:\Users\fadel\Documents\MATLAB\myplotfunction1.m>>
clear all;
clc;
function myplotfunction(equation)
x=linspace(-10,10,100);
y=eval(equation);
figure;
plot(x,y,'lineWidth',2)
title(['Représentation graphique de la fonction : ' equation]);
xlabel('x');
ylabel('y');
grid on;
end
댓글 수: 2
Steven Lord
2024년 1월 19일
Delete these two lines from your file. They make your file a script file, not a function file, and you can't call a script with input arguments like you call a function.
clear all;
clc;
Walter Roberson
2024년 1월 19일
The
clear all
clc;
makes that into a script. Get rid of those.
카테고리
도움말 센터 및 File Exchange에서 Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!