필터 지우기
필터 지우기

Inner matrix must agree

조회 수: 2 (최근 30일)
Alejandro Urbina
Alejandro Urbina 2016년 2월 23일
댓글: Moe_2015 2016년 2월 23일
So im trying to run the following code...
A1=4; A2=-2; B1=3; B2=1; tau1=100*10^-3; tau2=20*10^-3; w=40*pi; x = linspace(0,2*pi,100); y1 = (A1*exp(-x/tau1))+(A2*exp(-x/tau2)); y2 = (A1*exp(-x/tau1))+(A2*(x/tau1)*exp(-x/tau1)); y3 = (exp(-x/tau1)*(B1*cos(w*x)+B2*sin(w*x))); figure plot(x,y1,'--',x,y2,':',x,y3,'r')
I get the following error:
Error using * Inner matrix dimensions must agree.
Error in Urbina_ps1 (line 10) y2 = (A1*exp(-x/tau1))+(A2*(x/tau1)*exp(-x/tau1));
I dont know how to solve the matrix problem that is happening in the sencond termn of the equation... Im new to matlab and i have been looking for tutorials to trying to solve this...
Ill appreciate any help thank you

답변 (1개)

Moe_2015
Moe_2015 2016년 2월 23일
편집: Moe_2015 2016년 2월 23일
It's because of the x variable. Your x variable is a row vector of a 100 elements. When you use "*" by itself it is doing matrix multiplication. Thus, throughout your code you are trying to multiply a 1X100 vector with another 1X100 vector which is not possible. You should replace all "*" with ".*" as this will allow you to do element wise multiplication.
  댓글 수: 2
Alejandro Urbina
Alejandro Urbina 2016년 2월 23일
thank you Moe_2015!!!
Moe_2015
Moe_2015 2016년 2월 23일
You are welcome. If this helped you with your problem please accept the answer for the benefit of others.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by