How to perform element-wise matrix multiplication in simulink?

조회 수: 2 (최근 30일)
Priya
Priya 2014년 9월 8일
편집: Priya 2014년 9월 8일
Hi,
I have modelled the equations below in Simulink and I wanted to check them through simulation. But when modelled in Simulink they give an error.
s_x_index = 0:0.0001:0.02;
for i = 1:length(s_x_index)
x_a(i) = s_x_index(i);
epsilon_x=1/4.*[(G.*pi.*a1.*b1.*c_11.*s_x_index)/(Q.*cof)];
F=(2*Q*cof/pi).*[(k_A*epsilon_x)./(1+(k_A*epsilon_x).^2)+atan(k_S*epsilon_x)];
I have posted only few lines of the code and not the entire coding thinking that this is enough to explain, please let me know if you need further information.
Please find attached the block in the model which cause the error. The error is,
Error using test_file (line 429) Error evaluating parameter 'Value' in 'force/Constant7'
Caused by: Error using test_file (line 429) Inner matrix dimensions must agree.
The size of the parameters are given below,
>> size(a1)
ans =
1 1
>> size(b1)
ans =
1 1
>> size(G)
ans =
1 1
>> size(c_11)
ans =
1 1
>> size(s_x_index)
ans =
1 201
Please do help out.
Thanks.

답변 (1개)

Oyeniyi
Oyeniyi 2014년 9월 8일
Perhaps you want to ensure element-wise multiplication and division. The 2nd division in 'epsilon_x' is the matrix type. As you haven't given the size of the other parameters (Q, cof etc), one cannot know for sure the intended type of operation. Try
epsilon_x=1/4.*[(G.*pi.*a1.*b1.*c_11.*s_x_index)./(Q.*cof)]; F=(2*Q.*cof/pi).*[(k_A.*epsilon_x)./(1+(k_A.*epsilon_x).^2)+atan(k_S.*epsilon_x)];
  댓글 수: 1
Priya
Priya 2014년 9월 8일
편집: Priya 2014년 9월 8일
Thanks for your reply. I tried your suggestion, but it didn't work. The thing is I don't have any problem with the coding, I'm just trying to model the same equation of F in Simulink. So I have to follow the coding to model this equation in Simulink.
>> size(Q)
ans =
1 1
>> size(cof)
ans =
1 1

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

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by