Vadc <Vdisp is no longer true for the first time and I want the values to hold the same values of else even if Vadc <Vdisp is true again.
function [G,S] = f(H,clock,T,Vadc,Vdisp,R)
if (clock>T+R+0.2)
if (Vadc<Vdisp)
G=H;
S=1;
else
G=pulse;
S=0;
end
else
G=H;
S=1;
end

댓글 수: 3

Adam Danz
Adam Danz 2019년 4월 1일
There are no loops in your function so every time your function is executed, it's "the first time".
It seems like you want your function to behave in different ways depending on inputs from previous funciton calls and that sounds like a train wreck in slow motion. For example, you start Matlab for the day, on the first call to your 'f' function, the first 'else' is satisfied. Does that mean for the rest of the day (or week, or whenever matlab is shut down again) the first part of that condition should always be ignored?
Also, what is the 'pulse' variable (or function?) - it's not defined in your function.
Inês Correia
Inês Correia 2019년 4월 1일
편집: Inês Correia 2019년 4월 1일
My problem is that my values are arrays. Pulse is a variable. I forgot that part.
Adam Danz
Adam Danz 2019년 4월 1일
편집: Adam Danz 2019년 4월 1일
Why is that a problem? Could you provide a complete example that demonstrates the problem?
Also, your variable 'pulse' is never defined in this function. Is it a global variable (if yes, reconsider this choice).

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

답변 (0개)

카테고리

질문:

2019년 4월 1일

편집:

2019년 4월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by