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));
I actually want to manipulate individual elements of my block
blocks made of 8x8 values ranging from 0-255
Athul Prakash 2020 年 11 月 24 日
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
% skipping the 2nd block.
out = block_struct.data;
% code for processing every other element
Hope it helps!