I have a loop containing about 6 operations, there is a logic statement that applies to 5/6 of the functions.
2 views (last 30 days)
Show older comments
Ryan Driver on 27 Jan 2022
Commented: Rik on 27 Jan 2022
I have a long loop that has 6 functions, 5 of which adhere to the logic statement. I only need one of the functions to follow it's own statment, and trying to individually input the logic statment for the other 5 has proved difficult.
op==5 is the only one that needs to follow it own statment. i.e not caring about a2 in the input. It should only care about a1, but the statment at the beginning return this operation as 0 when it should be computated. Any help is greatly appreciated.
Max Heimann on 27 Jan 2022
Something like this?
function [status, result] = func(op,a1,a2)
status = 0;
result = 0;
[row1,col1] = size(a1)
if row1 ~= col1
[row2,col2] = size(a2)
if row2 ~= col2
You are implementing several functions now. You should consider splitting up your function to several parts. You can use varargin and varargout in your main function and use a switch statement to perform the relevant operation in a separate function.
%documentation goes here
varargout=cell(1,nargout); % create output array
error('operation not implemented')
Find more on Multirate Signal Processing 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!