Is it a loop problem ?
显示 更早的评论
Hello, this program needs to count the number of colors every 15 minutes for 6 hours (0:24 iteration).at the end of each iteration a graph is shown with all the colors and, at the end of the loop one more graph shows the amount of each color and the max and min. the problem I encountered is that the program asks the dimension of the matrix each time and shows the max/min graphs after each one but, I would like the program to ask for the dimension only one time and to show the max/min and amount per time frame only at the end of the loop for all colors.
the script is in the .xlsx file.
helping solve the issue will be much appreciated, guys.
2 个评论
waqas
2020-7-21
Goood idea would be to just paste the code as .m file so that it can be easily implemented. Right now it is not very clear.
Netanel malihi
2020-7-21
采纳的回答
更多回答(1 个)
Netanel malihi
2020-7-22
0 个投票
4 个评论
waqas
2020-7-22
Update the function MatrixDimInput with these lines and this should work fine.
function [m,n]=MatrixDimInput(m_in,n_in)
errorFlag=0 %errorFlag=0 if there is no error in the input. errorFlag=1 if an error is found.
while 1
if (m_in>=4 && m_in<=10 && n_in>=7 && n_in<=12 && rem(m_in,1)==0 && rem(n_in,1)==0)
errorFlag=0 %no errors found
m = m_in;
n = n_in;
break
else
errorFlag=1 %Error is found
error='The dimensions you entered are incorrect. \n Please make sure that m is between 4 to 10, and n is between 7 to 12. \n Enter m (4 to 10): '
error2='Enter n (7 to 12): '
m_in=input(error)
n_in=input(error2)
end
end
m = m_in;
n = n_in;
end
Netanel malihi
2020-7-22
Netanel malihi
2020-7-23
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
