how to check time in if statement?

In if statement i want to check the timing of the signal . I mean for zero second output is 5 else 2 . And this repeats for few other conditions of time.
like,
If t=0
res=5;
elseif t=6
res=7;
else
res=0;
(all times in seconds)

3 Comments

See examples of correct usage of if statements testing for equality
can I use vector in if to check condition?
Time is in vector and I want to check the test at particular time.

Sign in to comment.

Answers (1)

KSSV
KSSV on 1 Feb 2021
Read about tic toc.

6 Comments

I want to generate pulse train at different times.Not just integers.
if time=0 %ns
result =0;
elseif time =20 %ns
result=3;% rising edge(in volt)
elseif time=35 %in ns
result= 0;% falling edge
elseif time =45 %in nano sec
result =4 % in volt
else
result=0;
I am getting error if i use time in if statement.
Show us the complete code and the error.
The error is here
If t=0
and the OP should be able to figure this one out by looking at examples in the documentation.
I am using step block from simulink ,to get 5 amplitude i multiplied it with 5 from matlab function
code is written in matlab and step block is from simulink
Consider,
i want
0 to 100ns output zero ,
100 to 300 o/p 5 volt
300 to 500 o/p 0
500to 700 o/p 5
700 to 900 o/p 0
and till simulation time o/p zero.
Got my question?
> Got my question?
We're asking you that question. What questions do you have?

Sign in to comment.

Categories

Find more on Simulink in Help Center and File Exchange

Asked:

on 1 Feb 2021

Commented:

on 1 Feb 2021

Community Treasure Hunt

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

Start Hunting!