필터 지우기
필터 지우기

seperating integer values using if block in simulink

조회 수: 1 (최근 30일)
kumaresan
kumaresan 2012년 11월 3일
I have integers [1 2 3 5 6 7 8 9 10] and function f(x) and g(x), I specified those ingeters in a constant block labled x. In the command window I specified x=[1 2 3 4 5 6 7 8 9 10]. another variable y is specified as 5 in the command window, y=5. For integers x=>5 function f(x) is computed and for integers x<5 function g(x) is computed. I used the if block to perform this condition. when i run the simulation this error comes up.
Error in port widths or dimensions. Output port 1 of 'model/constant,x2' is a one dimensional vector with 10 elements.
i think the if block could not take all the values at the same time.
how do i go about this? is there any other way to do this?
thank you. your guidance is very much appreciated.
  댓글 수: 2
Azzi Abdelmalek
Azzi Abdelmalek 2012년 11월 3일
can you post your model
kumaresan
kumaresan 2012년 11월 5일
this is the link to my model. i have renamed 'y' as 'a'.

댓글을 달려면 로그인하십시오.

채택된 답변

Raju Purohit
Raju Purohit 2012년 11월 4일
I cannot be sure unless you post your model but I think the problem arising in your model is by this: in the block parameters of "If block" under "If expression", you have used u1 >= 5 (ie., x >= 5) which is incorrect. x is a vector with the order 1x10, while on the right hand side is 5 which is a 1x1 integer. MATLAB cannot compare the two dimensionally mismatching variables.
Instead, you need to use u1(i) >= 5, where i can be anywhere between 1 and 10, in which case u1(i) will be a 1x1 variable and can be compared to 5.
Hope this helps.
  댓글 수: 3
Raju Purohit
Raju Purohit 2012년 11월 6일
I think you have to reconsider your logic. You can set only one condition for an "if" block. But in your case, you have 10 simultaneous conditions, and thus you have to build logic accordingly. What I am guessing is that you want to send 10 integers 'one by one' and make the "if" block work accordingly. Can you explain me what exactly you want so that I can be more helpful? Also, you uploaded image is barely readable.
kumaresan
kumaresan 2012년 11월 21일
your guess is correct. I do want to send 10 integers 'one by one' and make the "if" block work accordingly. I want the if box to send the integers to the block based on my conditions which is >5 and <5. so what i want is for the 'if block' to recognise the integer, then if the integer is more then 5, it is sent to a subsystem and if its less then 5 its sent to another subsystem for further calculations. For starters I'm only using 10 integers later on i will use more integers.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by