Filter löschen
Filter löschen

How to commit statement only under certain conditions?

2 Ansichten (letzte 30 Tage)
LamaObecna
LamaObecna am 26 Feb. 2017
Bearbeitet: LamaObecna am 27 Feb. 2017
Hello, I'm simulating water heating and I need to create certain condition and I dont know how to create it properly.
Required temperature of water is 55 °C. Minimal temperature is 50 °C. Maximum temperature is 70 °C.
I have 2 types of heating - electrical heating which heats water to required temperature 55 °C and photovoltaic heating which can heat water to maximum temperature.
I need to create condition which turn on electrical heating only if temperature drops below 50 °C and stops after reaching 55 °C. If the temperature is between 50 and 55 without dropping under 50 °C only photovoltaic heating is possible and electrical heating is off.
Temperature is checked every minute for whole year. Conditions will be placed in for cycle. I dont know how to create condition for starting electrical heating under 50 and stopping at 55.
Something like that:
if temperature < 70
photovoltaic on
else
everything off
if temperature < 50
electrical heating on and stops at 55°C
Thanks for advice.

Akzeptierte Antwort

Jan
Jan am 26 Feb. 2017
Bearbeitet: Jan am 26 Feb. 2017
electric = true;
photovoltaic = false;
for iMinute = 1:365*24*60
if temperature(iMinute) < 50
electric = true;
elseif temperature(iMinute) > 55
electric = false;
end
photovoltaic = (temperature(iMinute) < 70);
...
end
  7 Kommentare
Jan
Jan am 27 Feb. 2017
Bearbeitet: Jan am 27 Feb. 2017
@LamaObencna: The code you have shown here, does not contain the code for changing the temperature. The part of detecting, which heating is enabled, was discussed exhaustively already, and it cannot cause the observed behavior alone. You can replace it for testing: Keep the photovoltaic and/or electric heating enabled manually and examine, what happens.
Something like "it ignores 55 °C condition" cannot happen. Matlab is not in a bad mood and ignores any line. I really want to help you and I'm convinced the problem is not included in the part of the code, which has been posted here. So please start testing the code I've suggested if it enables the heat sources exactly as you want it. Then we can proceed and find out, why the correct values do not yield the expected result in the change of the temperature.
LamaObecna
LamaObecna am 27 Feb. 2017
Bearbeitet: LamaObecna am 27 Feb. 2017
Done. I figured it out with help of community of stackoverflow, basicly very similar to your idea. I should show whole code, it would be easier to get it work, my mistake. Anyway, thank you for your time and advice. I have marked your answer as accepted becouse it was right direction.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Thermal Analysis finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by