filename input into function
37 次查看(过去 30 天)
显示 更早的评论
Really basic question, I have just started using MatLab. I have a function that pulls specific columns out of arrays that could be in any of four data files I am working with. Thus, my goal is to input a filename, have the function load the file, and then return the specific columns. Here is my current function:
function [tlat, trate] = lss_rr(filename)
G = load(filename)
m = G(:,3)
t = G(:,4)
But when I input a filename, the name returns as an undefined variable.
回答(2 个)
Walter Roberson
2018-3-3
[TL, TR] = lss_rr('YourFile.txt');
Change YourFile.txt to the name of your file.
Do not try to use [TL, TR] = lss_rr(YourFile.txt); as that will try to evaluate YourFile as a variable.
0 个评论
luis suarez
2019-9-20
When i type this command in matlab
function power_flow(filename)
Where filename is a .txt file
It says undefined variable. Can somebody help me please.
4 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!