how do i make my function accept filename as input ?

hi, i have a function that i want to accept an excel filename as an input so it can load that file, i have been unable to get it to accept that , ive tried using filename as an input
function [ theta , xLand ] = ProjectileData(fileName)
%UNTITLED8 Summary of this function goes here
% Detailed explanation goes here
data = xlsread('fileName');
theta = data(:,1);
xLand = data(:,2:end);
aveDis = mean(xLand , 2);
if nargout == 0
plot (theta , aveDis)
end
end

댓글 수: 1

Why do you think the function does not accept the filename?

댓글을 달려면 로그인하십시오.

 채택된 답변

Stephen23
Stephen23 2017년 2월 15일
편집: Stephen23 2017년 2월 15일
Change this line so it uses the variable filename instead of the string 'filename':
data = xlsread(fileName);

댓글 수: 1

khaled almutairi
khaled almutairi 2017년 2월 15일
편집: khaled almutairi 2017년 2월 15일
tried it , didn't work
EDIT : never mind , it works now, thanks

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

태그

질문:

2017년 2월 15일

편집:

2017년 2월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by