MATLAB: How to create legend for two error bar plots

legendplotting

The only problem with my code is, that the legend line gives error messages and doesn't show up in the graph. I want a legend with 4 elements (The data of graph 1, the fit of graph 1, the data of graph 2, the fit of graph 2). I don't want the error bars to show in the legend. My code:
function [fitresult, gof, goft] = Linearized_plot_both(inverse_square_radius,time,er,inverse_square_radiust,timet,ert)
%%Fit: 'Linearized Fit'.
[xData, yData] = prepareCurveData( inverse_square_radius, time );
[xDatat, yDatat] = prepareCurveData( inverse_square_radiust, timet );
% Set up fittype and options.
ft = fittype( 'poly1' );
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft );
[fitresultt, goft] = fit( xDatat, yDatat, ft );
% Plot fit with data.
figure( 'Name', 'Comparing Linearized Fit' );
x= linspace(0,11e5);
y=(fitresult.p1).*x + (fitresult.p2);
h=plot(xData,yData,'.k',x,y,'b');
h(1).MarkerSize = 12;
h(2).LineWidth = 1;
hold on;
axis([0 10.5e5 0 41.5]);
grid on;
hEB=errorbar(xData,yData,er,'.k', 'MarkerFaceColor','k','MarkerEdgeColor','k','MarkerSize',12);
xt= linspace(0,11e5);
yt=(fitresultt.p1).*x + (fitresultt.p2);
ht=plot(xDatat,yDatat,'.k',xt,yt,'r');
ht(1).MarkerSize = 12;
ht(2).LineWidth = 1;
hold on;
hEBt=errorbar(xDatat,yDatat,ert,'.k', 'MarkerFaceColor','k','MarkerEdgeColor','k','MarkerSize',12);
legend([h,ht],'time vs. inverse_square_radius (Data)','Linearized Fit (Data)','time vs. inverse_square_radius (Theory)','Linearized Fit (Theory)');
% Label axes
xlabel inverse_square_radius
ylabel time
The produced graph:
Way I want my legend to look (just for both graphs):
%

Best Answer

h and ht are column vectors of handles and you've concatenated them into a 2x2 array instead of a vector...it's trying to put those together inside legend that's failing.
Use ; instead of , --
legend([h;ht],'time vs. inverse_square_radius (Data)','Linearized Fit (Data)','time vs. inverse_square_radius (Theory)','Linearized Fit (Theory)');
You'll probably cover up most of the plot area with the length of the text, but that's another problem... :)