当前位置:编程问答 > Matlab >

急 关于matlab的。我编了一段程序,但是怎么都弄不出结果。求高手给我看下哪里出错了啊。谢谢了

问题:% exam2 clear float z1; float z2; float s1; float s2; float t1; float t2; float c; z1=input('z1_zhi','s') z2=input('z2_zhi','s') s1=input('s1_zhi','s') s2=input('s2_zhi','s') t1=input('t1_zhi','s') t2=input('t2_zhi','s') c=input('c_zhi','s') A=[s1.*s1.*s1.*s1 s1.*s1.*s1.*s1.*s1.*s1 s1.*s1.*s1.*s1.*s1.*s1.*s1.*s1 s1.*s1.*s1.*s1.*s1.*s1.*s1.*s1.*s1.*s1 换行 4.*s1.*s1.*s1 6.*s1.*s1.*s1.*s1.*s1 8.*s1.*s1.*s1.*s1.*s1.*s1.*s1 10.*s1.*s1.*s1.*s1.*s1.*s1.*s1.*s1.*s1 换行 s2.*s2.*s2.*s2 s2.*s2.*s2.*s2.*s2.*s2 s2.*s2.*s2.*s2.*s2.*s2.*s2.*s2 s2.*s2.*s2.*s2.*s2.*s2.*s2.*s2.*s2.*s2 换行 4.*s2.*s2.*s2 6.*s2.*s2.*s2.*s2.*s2 8.*s2.*s2.*s2.*s2.*s2.*s2.*s2 10.*s2.*s2.*s2.*s2.*s2.*s2.*s2.*s2.*s2] B=[z1-c.*s1.*s1 t1-c.*s1 z2-c.*s2.*s2 t2-c.*s2]' x=A./B 但是最后出来的结果是: ??? Error using ==> vertcat All rows in the bracketed expression must have the same number of columns. Error in ==> exam2 at 17 A=[s1.*s1.*s1.*s1 s1.*s1.*s1.*s1.*s1.*s1 s1.*s1.*s1.*s1.*s1.*s1.*s1.*s1 s1.*s1.*s1.*s1.*s1.*s1.*s1.*s1.*s1.*s1 求高手帮忙解答下啊 谢谢
答案:两个错误:1.键盘接收的是字符,不是float型的数据。
2.A和B的维数不对,矩阵好像没有除法吧?
大概改了一下,不知楼主的A./B到底是准备求什么,所以结果你再看看。。

clear
clc
z1=input('z1_zhi\n','s');z1= str2double(z1);
z2=input('z2_zhi\n','s');z2= str2double(z2);
s1=input('s1_zhi\n','s');s1= str2double(s1);
s2=input('s2_zhi\n','s');s2= str2double(s2);
t1=input('t1_zhi\n','s');t1= str2double(t1);
t2=input('t2_zhi\n','s');t2= str2double(t2);
c=input('c_zhi\n','s');c= str2double(c);
A1=[s1.*s1.*s1.*s1        s1.*s1.*s1.*s1.*s1.*s1 ...
  s1.*s1.*s1.*s1.*s1.*s1.*s1.*s1    s1.*s1.*s1.*s1.*s1.*s1.*s1.*s1.*s1.*s1];
A2=[4.*s1.*s1.*s1    6.*s1.*s1.*s1.*s1.*s1  ...
   8.*s1.*s1.*s1.*s1.*s1.*s1.*s1     10.*s1.*s1.*s1.*s1.*s1.*s1.*s1.*s1.*s1 ];
A3=[s2.*s2.*s2.*s2   s2.*s2.*s2.*s2.*s2.*s2  ...
  s2.*s2.*s2.*s2.*s2.*s2.*s2.*s2    s2.*s2.*s2.*s2.*s2.*s2.*s2.*s2.*s2.*s2];
A4=[4.*s2.*s2.*s2    6.*s2.*s2.*s2.*s2.*s2   ...
 8.*s2.*s2.*s2.*s2.*s2.*s2.*s2     10.*s2.*s2.*s2.*s2.*s2.*s2.*s2.*s2.*s2];
B=[z1-c.*s1.*s1  t1-c.*s1  z2-c.*s2.*s2  t2-c.*s2];
x1=A1./B %或是A/B
x2=A2./B %或是A/B
x3=A3./B %或是A/B
x4=A4./B %或是A/B

上一个:matlab 高手指点
下一个:Matlab 2010a键入字母与显示不同,怎么改啊?

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,