User Input - Max and min temperature
2 次查看(过去 30 天)
显示 更早的评论
I am trying to resolve an exercise. I need to:
- Create diario_temp
- Save diario_temp in temperaturas.mat
- User input: Temperature min
- User input: Temperature max
- Verify if temperature max is superior than temperature min
- Then, shown hours of the day is superior than user input: Temperature min and inferior than user input: Temperature max
I am having an hard time, if you have any suggestion I will appreciated.
% Criação do ficheiro temperaturas.mat
diario_temp=[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23;7.2 7.0 6.77 6.2 6 4.9 4.5 4.7 5.1 7.3 8.5 12.1 13.9 14.2 15.1 16 14.1 12.2 11.4 10.5 9.5 8.7 7.2 6.1];
save('temperaturas.mat','diario_temp')
% Perguntar ao utilizador a temperatura mínima
TempMin = input('Qual a temperatura mínima? ', 's');
disp(['Temperatura mínima: ', TempMin]);
% Perguntar ao utilizador a temperatura máxima
TempMax = input('Qual a temperatura máxima? ', 's');
disp(['Temperatura máxima: ', TempMax]);
% Verificar condição Temperatura máxima >= Temperatura mínima
if((TempMax) >= (TempMin))
% load('temperaturas.mat')
% idx=find(diario_temp > 5)
% value=diario_temp(idx)
% whos -file temperaturas.mat
else((TempMax) <= (TempMin));
disp('A Temperatura Máxima é menor que a Temperatura Mínima !!!')
end
4 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!