How to use IF with @(block_struct) function
6 views (last 30 days)
Show older comments
Saud Alfalasi
on 22 Nov 2020
Edited: Saud Alfalasi
on 24 Nov 2020
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
Accepted Answer
Athul Prakash
on 24 Nov 2020
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 Comments
More Answers (0)
See Also
Categories
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!