【发布时间】:2013-06-16 19:58:32
【问题描述】:
我正在使用 MATLAB 处理文件中的数据。我正在编写一个程序,该程序从用户那里获取输入,然后在绘制它们的目录中找到特定文件。文件命名:
{name}U{率}
{name} 是表示计算机名称的字符串。 {rate} 是一个数字。这是我的代码:
%# get user to input name and rate
NET_NAME = input('Enter the NET_NAME of the files: ', 's');
rate = input('Enter the rate of the files: ');
U = strcat(NET_NAME, 'U', rate)
load U;
Ux = U(:,1);
Uy = U(:,2);
目前有两个问题:
当我执行
strcat时说 'hello'、'U' 并且速率为 50,U 将存储 'helloU2' - 我怎样才能让strcat正确附加 {rate}?加载行 - 如何取消引用 U 以便加载尝试加载存储在 U 中的字符串?
非常感谢!
【问题讨论】:
-
1. filename = sprintf("%s.%d", name, rate)
2. fdata = load(filename)
标签: string matlab-load