Simulink element wise multiplication for big data
古いコメントを表示
Hi all,
I'm new to simulink. In matlab i run a function which takes 100000*10 size of data and gives an output of 100000*1 within 2 sec as the function is taking element wise multiplication(.*) instead of running in a for-loop row by row. I want to implement this function in simulink to take the advantage of blocks(to edit the formula easier in later stages). I've created my model but when i try to run the simulation, my laptop freezes(may be because of out of memory). How to perform element wise multiplication instead of time based simulation? Is simulink only for time based simulation? Sample program,
data=rand(100000,10);
map.BP_x=[1,2,3,4,5,6];map.BP_y=[1,2,3,4,5,6];map.data=rand(6,6);
function output=my_fun(data,map)
interpolation_data=interp2(map.BP_x,map.BP_y,map.data);
output=interpolation_data*data(:,1)+data(:,2)+data(:,3)+data(:,4)+data(:,5)+...;
end
5 件のコメント
dpb
2018 年 10 月 13 日
interpolation_data=interp2(map.BP_x,map.BP_y,map.data);
is bad syntax; the sample values array map.data must be the first argument, not the last.
interpolation_data=interp2(map.data,map.BP_x,map.BP_y);
What is the result of
output=interpolation_data*data(:,1)+data(:,2)+data(:,3)+data(:,4)+data(:,5)+...
supposed to be? You speak of element-wise multiplication in the Q? text but use array multiply in the above. Either way, the dimensions aren't consistent as you have sizes for the operation as
[1x6]*[100000x1] + [100000x1] + [100000x1] + ...
First need to define what it is you're actually trying to calculate.
dpb
2018 年 10 月 15 日
So now instead you have
[100000x1] * [100000x1] + [100000x1] + [100000x1] + ...
You still have a size issue with the matrix multiply and you've yet to specify what you expect the result to be.
Don't let the size of the array get in the way, it doesn't matter if the array length is 10^9 or just 10, matrix multiply must be conformant in the inner dimensions or use element-wise operator if it is the point-by-point product of elements between the two vectors you are trying to compute.
Only you know what it is you're trying to calculate...
BTW, presuming the last terms in the expression of X(:,2)+X(:,3)+... is correct, write that as
sum(X(:,2:8),2)
instead.
Vick
2018 年 10 月 15 日
dpb
2018 年 10 月 15 日
output=interpolation_data.*data(:,1)+sum(data(:,2:8),2);
I've never even seen a Simulink installation so I've zero knowledge about how it actually operates.
I thought a S-function would operate to compute its result with the current inputs at each timestep evolution???
If that's not so, I have nothing I can add, sorry.
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Signal Attributes and Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!