Filter löschen
Filter löschen

How to perform element-wise matrix multiplication in simulink?

1 Ansicht (letzte 30 Tage)
Priya
Priya am 8 Sep. 2014
Bearbeitet: Priya am 8 Sep. 2014
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.

Antworten (1)

Oyeniyi
Oyeniyi am 8 Sep. 2014
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 Kommentar
Priya
Priya am 8 Sep. 2014
Bearbeitet: Priya am 8 Sep. 2014
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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu General Applications finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by