フィルターのクリア

Input definition in "MATLAB System" block not necessary?

4 ビュー (過去 30 日間)
Manu
Manu 2022 年 1 月 10 日
回答済み: Prateekshya 2023 年 9 月 26 日
Looking at a MATLAB System block that I wrote a while ago, I noticed that I didn't properly specify the inputs. The code works but I don't remember why I did it this way or if it could create a problem at some point. The functions getInputDataTypeImpl, isInputComplexImpl and isInputFixedSizeImpl only have one element, instead of seven.
Does Matlab automatically copy the settings for the other six inputs?
function num = getNumInputsImpl(~) % Number of inputs
num = 7;
end
function num = getNumOutputsImpl(~) % Number of outputs
num = 8;
end
function [dt1, dt2, dt3, dt4, dt5, dt6, dt7, dt8] = getOutputDataTypeImpl(~) % Output data type
dt1 = 'double';
dt2 = 'double';
dt3 = 'double';
dt4 = 'double';
dt5 = 'double';
dt6 = 'double';
dt7 = 'double';
dt8 = 'double';
end
function dt1 = getInputDataTypeImpl(~) % Input data type
dt1 = 'double';
end
function [sz1, sz2, sz3, sz4, sz5, sz6, sz7, sz8] = getOutputSizeImpl(obj) % Output dimensions
sz1 = [1, obj.nIn];
sz2 = [obj.N+1, obj.nState];
sz3 = [obj.N, obj.nOut];
sz4 = [obj.N, obj.nIn];
sz5 = [obj.N, 1];
sz6 = [obj.N, 1];
sz7 = [obj.N, 1];
sz8 = [1, obj.nOut];
end
function [sz1, sz2, sz3, sz4, sz5, sz6, sz7] = getInputSizeImpl(obj) % Input dimensions
sz1 = [obj.nState, 1];
sz2 = [obj.N, obj.nDst];
sz3 = [obj.N, 1];
sz4 = [obj.N, 1];
sz5 = [obj.N, 1];
sz6 = [obj.N, 1];
sz7 = [1, 1];
end
function cp1 = isInputComplexImpl(~) % Inputs are complex numbers?
cp1 = false;
end
function [cp1, cp2, cp3, cp4, cp5, cp6, cp7, cp8] = isOutputComplexImpl(~) % Outputs are complex numbers?
cp1 = false;
cp2 = false;
cp3 = false;
cp4 = false;
cp5 = false;
cp6 = false;
cp7 = false;
cp8 = false;
end
function fz1 = isInputFixedSizeImpl(~) % Input fixed size?
fz1 = true;
end
function [fz1, fz2, fz3, fz4, fz5, fz6, fz7, fz8] = isOutputFixedSizeImpl(~) % Output fixed size?
fz1 = true;
fz2 = true;
fz3 = true;
fz4 = true;
fz5 = true;
fz6 = true;
fz7 = true;
fz8 = true;
end

回答 (1 件)

Prateekshya
Prateekshya 2023 年 9 月 26 日
Hi Manu,
As per my understanding you want to know the usage of "tilde" (~) in MATLAB function arguments.
This operator is used for the unused input arguments. The corresponding input arguments, which are replaced by "tilde" (~) are ignored. For more information you can follow this link: https://in.mathworks.com/help/matlab/matlab_prog/ignore-function-inputs.html
I hope this helps!

カテゴリ

Help Center および File ExchangeSimulink Functions についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by