多输入matlab

多输入matlab,matlab,Matlab,您能告诉我如何在matlab中从用户处获得多个输入吗?我曾想过直接获得一个数组,但这似乎不可能。我尝试了以下方法 velocity = input('Enter the velocities you want the aircraft to have at every node with space in between(m/s)','s'); 然后使用分隔符读取空格之间的数字。但即便如此,我也不知道如何使用内置函数 [u,remain] = strtok(velocity

您能告诉我如何在matlab中从用户处获得多个输入吗?我曾想过直接获得一个数组,但这似乎不可能。我尝试了以下方法

     velocity = input('Enter the velocities you want the aircraft to have at every node with space in between(m/s)','s');
然后使用分隔符读取空格之间的数字。但即便如此,我也不知道如何使用内置函数

     [u,remain] = strtok(velocity);
如果无法直接获取多个输入,我如何将上述内容放入循环中,以便读取所有数字?如果问题非常简单,我深表歉意,我们将非常感谢您的帮助。

将数组作为输入

>> velocity = input('Enter the velocities you want the aircraft to have at every node with space in between(m/s)','s');
Enter the velocities you want the aircraft to have at every node with space in between(m/s) [1 2 3]
>> velocity

velocity =

 [1 2 3]
然后可以使用速度1,速度2。。。等等

或者,如果您计划以逗号分隔的方式输入,请使用正则表达式

>> velocity = input('Enter the velocities you want the aircraft to have at every node with space in between(m/s)','s');
Enter the velocities you want the aircraft to have at every node with space in between(m/s)1,2,3
>> result=regexp(velocity,',','split')

result = 

    '1'    '2'    '3'
同样,您也可以使用空格来分隔输入

将数组作为输入

>> velocity = input('Enter the velocities you want the aircraft to have at every node with space in between(m/s)','s');
Enter the velocities you want the aircraft to have at every node with space in between(m/s) [1 2 3]
>> velocity

velocity =

 [1 2 3]
然后可以使用速度1,速度2。。。等等

或者,如果您计划以逗号分隔的方式输入,请使用正则表达式

>> velocity = input('Enter the velocities you want the aircraft to have at every node with space in between(m/s)','s');
Enter the velocities you want the aircraft to have at every node with space in between(m/s)1,2,3
>> result=regexp(velocity,',','split')

result = 

    '1'    '2'    '3'
同样,您也可以使用空格来分隔输入

这可以通过以下方式完成:

result = input('prompt');
Matlab将提示您输入“提示”,您可以输入例如[1 2 3]。结果将是向量,其中包含以前的数字

这可以通过以下方式实现:

result = input('prompt');

Matlab将提示您输入“提示”,您可以输入例如[1 2 3]。结果将是向量,其中包含以前的数字

感谢您的快速回复我觉得有个小错误。第一个,不直接给出数组。您必须删除输入参数末尾的“s”参数。感谢您的快速响应:我觉得有个小错误。第一个,不直接给出数组。必须删除输入参数末尾的“s”参数。