I am unable to execute a Nested if-else in MATLAB within a for loop. I have tried all I could to trace the error but still the error comes "At least one end is missing. The statement may begin here, pointing to the first if() of my Code. It would be really helpful if someone can help me out with this, as I have spent a lot of time but can't get through. Thanks!
fault_test_data = (fault_test_data)';
c= clock;
for i = 1:29736
if( (c(2) == fault_test_data(i,1)) & (c(3) == fault_test_data(i,2)) & (c(4) <= fault_test_data(i,3)))
if(fault_test_data(i,5) < 0 | fault_test_data(i,5) > 400)
fault_cause = strcat('Wind Direction is not in normal range! Present Wind Direction is', string(fault_test_data(i,5)), 'degree while normal range is 0.0040-359.9940 degree' );
disp_msg = msgbox('Fault is Predicted to Occur at', string(fault_test_data(i,3)), 'Hours', string(fault_test_data(i,4)), ' minutes as', fault_cause)
else if(fault_test_data(i,6) < cutin_speed | fault_test_data(i,6) > cutout_speed)
fault_cause = strcat('Wind Speed is not in normal range! Present Wind Speed is', string(fault_test_data(i,6)), 'm/s while normal range is 3.4570-26.7310 m/s' );
disp_msg = msgbox('Fault is Predicted to Occur at', string(fault_test_data(i,3)), 'Hours', string(fault_test_data(i,4)), ' minutes as', fault_cause)
else if(fault_test_data(i,7) < 258.0140 | fault_test_data(i,7) > 308.9580)
fault_cause = strcat('Air Temperature is not in normal range! Present Air Temperature is', string(fault_test_data(i,7)), 'K while normal range is 258.0140-308.9580 K' );
disp_msg = msgbox('Fault is Predicted to Occur at', string(fault_test_data(i,3)), 'Hours', string(fault_test_data(i,4)), ' minutes as', fault_cause)
else if(fault_test_data(i,8) < 8.2048e+04 | fault_test_data(i,8) > 8.5759e+04)
fault_cause = strcat('Air Pressure is not in normal range! Present Air Pressure is', string(fault_test_data(i,8)), 'Pa while normal range is 8.2048e+04-8.5759e+04 Pa' );
disp_msg = msgbox('Fault is Predicted to Occur at', string(fault_test_data(i,3)), 'Hours', string(fault_test_data(i,4)), ' minutes as', fault_cause)
else if(fault_test_data(i,9) < 0.9440 | fault_test_data(i,9) > 1.1030)
fault_cause = strcat('Density at Hub Height is not in normal range! Present Density at Hub Height is', string(fault_test_data(i,9)), 'Kg/m3 while normal range is 0.9440-1.1030 Kg/m3' );
disp_msg = msgbox('Fault is Predicted to Occur at', string(fault_test_data(i,3)), 'Hours', string(fault_test_data(i,4)), ' minutes as', fault_cause)
else
disp_msg = msgbox('No Upcoming Fault.')
break
end
end
end
Aucun commentaire:
Enregistrer un commentaire