2012-12-22 39 views
0

假設我有3個座標a(1,2),b(3,4)和c(5,6)。如何在matlab中插入輸入座標?

我如何使用「輸入」功能,使用戶可以輸入座標,並保存輸入的座標轉換爲矩陣形式插入。

例如A = input(......);

A = [1,2; 3,4; 5,6]

回答

0

如果希望一個線路輸入,就可以做到這一點

      % // a string ('s') is expected as input; 
          % // it'll be parsed expecting 6 
          % // real numbers space separated 
    A = sscanf(input('','s'), '%f %f %f %f %f %f'); 

,你可能想要做一個reshape

A = reshape(A,2,[])'; 

% // {Keyboard input}: 
     1 2 3 4 5 6 

% // returned value 

A = 
1  2 
3  4 
5  6 
+0

嗯,我看......這樣就成爲其中一種方式......非常感謝雅Acorbe =) – green