How to use IF with @(block_struct) function
6 ビュー (過去 30 日間)
表示 古いコメント
fun2 = @(block_struct) ...
if block_struct.data < 100
std2(block_struct.data) * (block_struct.data));
end
Doesnt work.
I actually want to manipulate individual elements of my block
blocks made of 8x8 values ranging from 0-255
採用された回答
Athul Prakash
2020 年 11 月 24 日
Hi Saud,
Since blockproc uses anonymous functions, you may save your multi-line function into a script, say myFunc.m and then pass @myFunc to your blockproc call.
You can find block_struct structure described in the following doc (under More About section): 'blockproc' Documentation.
You may work out a way to manage the sequence artificially using some of those fields. For example, using block_struct.location to skip processing the 2nd block:
function out = myFunc(block_struct) % size would be 100x100
if(block_struct.location(2)==101)
% skipping the 2nd block.
out = block_struct.data;
else
% code for processing every other element
end
end
Hope it helps!
3 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Find more on Direct Interface Communication in Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!