Code that is working in console, not working in the script?
Show older comments
Hello, I have a code that draws a bar chart for each month.
clf;
hold on;
len=length(in_mon); %in_mon is a vector of months i.e [2 4 1]
%there is data for 2012 and 2013, which is why there's two sets of datas
[pAvg1, pAvg2]=cal_month(len,date_1, date_2,wcf_1,wcf_2, in_mon); %returns the average for each month that was requested in in_mon with 2 vectors of len length
axis([0 len min(min(pAvg1), min(pAvg2)) max(max(pAvg1), max(pAvg2))]);
y=zeros(len,2);
for n=1:len %for loop is for orienting data properly for drawing bar
y(n,1)=pAvg1(n);
y(n,2)=pAvg2(n);
end
bar(in_mon',y);
xlabel('Month');
ylabel('WCF');
title('Average WCF');
legend('2012','2013');
^ This is the result of running the script, as you can see, no graph
^ This is the result of writing some of the code in console (using values that have already been defined with the previous script run). As you can see, that is a proper result.
I have no idea what is causing the script to fail, when the console seems to work. Any fixes?
Accepted Answer
More Answers (0)
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!