Bar diagram as subplot in a for loop from a cell
Show older comments
So i have a for loop which calculates some data and after i plot everything i want a subplot as a bar diagramm. I fit a linear curve to my data and want the gradient of the linear regression as the bar value. for each dataset is should take out the first value. If i try it with a simple example as at the end with a and b(i) it works fine but my bar diagramm only shows the value of p{1,1}(1) with the color of c{2} ? I am so confused and thankful for evey help.
number = numel(data)
for i = 1:number
p{i} = polyfit(x_relevant{i}, y_relevant{i},1)
subplot(4,1,4)
b(i) = bar(p{1,i}(1),'FaceColor',c{i}) % each data set, take out first value
hold on
a = {[1 2], [3 4]}
b(i) = a{1,i}(1)
end
Accepted Answer
More Answers (0)
Categories
Find more on 2-D and 3-D Plots 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!