hey,
I am reading a predefined array in a constant block in Simulink which then undergoes some simple logical operations like '<','>','and', etc. the output of which goes into an 'If' block.
This gives me an error as the input to the 'If' block has to be a single value and I seem to be inputting values of the length of my original array.
Is there some kind of a work around anyone could suggest?
Thanks, Dhruv

2 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 8 月 13 日
Can you give an example of your array?
Dhruv
Dhruv 2013 年 8 月 13 日
編集済み: Dhruv 2013 年 8 月 13 日
what I am looking to do is that I have an array of values and I need to delete some really small values from this array
say an array [10,17,12,2,9,4,21,18] and I want to remove all values below 5. So the 2 and 4 should be replaced by 0.
edit
I cannot use the Matlab function block as I need to compile my code and use it with TargetLink later.

サインインしてコメントする。

 採用された回答

Friedrich
Friedrich 2013 年 8 月 13 日
編集済み: Friedrich 2013 年 8 月 14 日

2 投票

Hi,
why not using a MATLAB function block with this code:
function y = fcn(u)
%#codegen
u(u<5) = 0;
y = u;
EDIT Way without MATLAB function block:
%

5 件のコメント

Dhruv
Dhruv 2013 年 8 月 13 日
I cannot use the function block as I need to compile my code and use it with TargetLink later.
Friedrich
Friedrich 2013 年 8 月 14 日
At least in the normal Simulink code gen area MATLAB functions blocks are supported for code gen. The above block will be transaltes to C and then get mex'ed when running the model. Is TargetLink unable to deal with MATLAB function blocks?
Dhruv
Dhruv 2013 年 8 月 14 日
the matlab function block cannot be compiled in C
Melik BEN MARZOUK
Melik BEN MARZOUK 2021 年 4 月 19 日
Ommgggg thank you so much! So clever!!!!
Keerthi Shankar
Keerthi Shankar 2022 年 3 月 18 日
If I want to take particular element from the array how can I take it I am trying to implement interpolation taking two constant blocks as array... Could anyone help me with this

サインインしてコメントする。

その他の回答 (3 件)

Kaustubha Govind
Kaustubha Govind 2013 年 8 月 13 日

0 投票

Perhaps you can AND all the bits in the array together?

2 件のコメント

Dhruv
Dhruv 2013 年 8 月 13 日
thanks for your answer.
The suggestion wouldnt work as I need to run the 'If' for every value in the array.
Dhruv
Dhruv 2013 年 8 月 13 日
what I am looking to do is that I have an array of values and I need to delete some really small values from this array

サインインしてコメントする。

Chandrasekhar
Chandrasekhar 2013 年 8 月 13 日

0 投票

have u tried using an assignment block
Dheeraj Kapur
Dheeraj Kapur 2017 年 7 月 13 日

0 投票

Hi, You can use a logic which I like to call the "moving" logic. You define the array in workspace, pass each of them into a decision box where if the value is less than 5 then replace it with 0; otherwise keep it same. Reconfigure the array on the other side and proceed as needed

カテゴリ

ヘルプ センター および File ExchangeEvent Functions についてさらに検索

製品

質問済み:

2013 年 8 月 13 日

コメント済み:

2022 年 3 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by