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 件のコメント

per isakson
per isakson 2017 年 2 月 15 日
Why do you think the function does not accept the filename?

サインインしてコメントする。

 採用された回答

Stephen23
Stephen23 2017 年 2 月 15 日
編集済み: Stephen23 2017 年 2 月 15 日

1 投票

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 ExchangeTables についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by