Why does my code does not work in the if loop
1 次查看(过去 30 天)
显示 更早的评论
Hi there,
The question ask us to filter out the temperatures that is less than 5 deg C. the output for my T variable is 1 by 539 double matrix. By applying if loop, how do i make temperature that is less than 5 deg C to be 0? The following is my codes:
beta=15; T0=56.2; %intial temperature
t=1:0.0167:10;
T=T0-beta*t;
for n=1:length(T)
if T(n)<5
T=0
end
end
there is an error: Index exceeds matrix dimensions. Please help
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!