Can anyone help me with integrating error bars?

4 次查看(过去 30 天)
My friend has helped me with writing the command for error bars but I am unsure of how to integrate it into the code to actually produce the error bars properly.
Currently, i have two codes, one with and oen without error bars, when i run the one with the error bars command, it skews the data.
I have the code written, it is extremely lengthy, so sorry about this, but if you just Ctrl+F to find error, you'll see where I would like the error bars to be.
Thanks
%% Plot pHluorin ratio of 395/475 for pH calibration
if Wavelength395==1
W395C1=W1C1;
W395C1STD=W1C1STD;
W395C2=W1C2;
W395C2STD=W1C2STD;
W395C3=W1C3;
W395C3STD=W1C3STD;
W395C4=W1C4;
W395C4STD=W1C4STD;
end
if Wavelength395==2
W395C1=W2C1;
W395C1STD=W2C1STD;
W395C2=W2C2;
W395C2STD=W2C2STD;
W395C3=W2C3;
W395C3STD=W2C3STD;
W395C4=W2C4;
W395C4STD=W2C4STD;
end
if Wavelength395==3
W395C1=W3C1;
W395C1STD=W3C1STD;
W395C2=W3C2;
W395C2STD=W3C2STD;
W395C3=W3C3;
W395C3STD=W3C3STD;
W395C4=W3C4;
W395C4STD=W3C4STD;
end
if Wavelength475==1
W475C1=W1C1;
W475C1STD=W1C1STD;
W475C2=W1C2;
W475C2STD=W1C2STD;
W475C3=W1C3;
W475C3STD=W1C3STD;
W475C4=W1C4;
W475C4STD=W1C4STD;
end
if Wavelength475==2
W475C1=W2C1;
W475C1STD=W2C1STD;
W475C2=W2C2;
W475C2STD=W2C2STD;
W475C3=W2C3;
W475C3STD=W2C3STD;
W475C4=W2C4;
W475C4STD=W2C4STD;
end
if Wavelength475==3
W475C1=W3C1;
W475C1STD=W3C1STD;
W475C2=W3C2;
W475C2STD=W3C2STD;
W475C3=W3C3;
W475C3STD=W3C3STD;
W475C4=W3C4;
W475C4STD=W3C4STD;
end
if pHluorin==1 & At_condition==1
pHluorinC1=W395C1./W475C1;
pHluorinC1STD=W395C1STD./W475C1STD;
if(At_minute<=max(TT)&&At_minute>=min(TT))
difference=abs(At_minute-TT);
[idx3 idx3]=min(difference);
pHluorinC1atT=pHluorinC1(:,idx3);
figure48=figure
plot(pHC1,pHluorinC1atT)
title('Condition 1')
ylabel('Ratio of 395/475 excitation')
xlabel('pH')
SinglePosition=TT(idx3);
potentialString=join(['Time point=',num2str(SinglePosition),' minutes']);
annotation('textbox',[0.153158999192897 0.854818787583294 0.177571428571429 0.0309523809523811],'String',potentialString, 'EdgeColor','none', 'BackgroundColor',[1 1 1])
legend('Ratio of 395/475')
ax13= gca;
end
end
if pHluorin==1 & At_condition==2
pHluorinC2=W395C2./W475C2;
pHluorinC2STD=W395C2STD./W475C2STD;
if(At_minute<=max(TT)&&At_minute>=min(TT))
difference=abs(At_minute-TT);
[idx3 idx3]=min(difference);
pHluorinC2atT=pHluorinC2(:,idx3);
figure49=figure
plot(pHC2,pHluorinC2atT)
title('Condition 2')
ylabel('Ratio of 395/475 excitation')
xlabel('pH')
SinglePosition=TT(idx3);
potentialString=join(['Time point=',num2str(SinglePosition),' minutes']);
annotation('textbox',[0.153158999192897 0.854818787583294 0.177571428571429 0.0309523809523811],'String',potentialString, 'EdgeColor','none', 'BackgroundColor',[1 1 1])
legend('Ratio of 395/475')
ax14= gca;
end
end
if pHluorin==1 & At_condition==3
pHluorinC3=W395C3./W475C3;
pHluorinC3STD=W395C3STD./W475C3STD;
if(At_minute<=max(TT)&&At_minute>=min(TT))
difference=abs(At_minute-TT);
[idx3 idx3]=min(difference);
pHluorinC3atT=pHluorinC3(:,idx3);
figure50=figure
plot(pHC3,pHluorinC3atT)
title('Condition 3')
ylabel('Ratio of 395/475 excitation')
xlabel('pH')
SinglePosition=TT(idx3);
potentialString=join(['Time point=',num2str(SinglePosition),' minutes']);
annotation('textbox',[0.153158999192897 0.854818787583294 0.177571428571429 0.0309523809523811],'String',potentialString, 'EdgeColor','none', 'BackgroundColor',[1 1 1])
legend('Ratio of 395/475')
ax15= gca;
end
end
if pHluorin==1 & At_condition==4
pHluorinC4=W395C4./W475C4;
pHluorinC4STD=W395C4STD./W475C4STD;
if(At_minute<=max(TT)&&At_minute>=min(TT))
difference=abs(At_minute-TT);
[idx3 idx3]=min(difference);
pHluorinC4atT=pHluorinC4(:,idx3);
figure51=figure
plot(pHC4,pHluorinC4atT)
title('Condition 1')
ylabel('Ratio of 395/475 excitation')
xlabel('pH')
SinglePosition=TT(idx3);
potentialString=join(['Time point=',num2str(SinglePosition),' minutes']);
annotation('textbox',[0.153158999192897 0.854818787583294 0.177571428571429 0.0309523809523811],'String',potentialString, 'EdgeColor','none', 'BackgroundColor',[1 1 1])
legend('Ratio of 395/475')
ax16= gca;
end
end
if pHluorin==1 & At_condition==5
pHluorinC1=W395C1./W475C1;
pHluorinC1STD=W395C1STD./W475C1STD;
if(At_minute<=max(TT)&&At_minute>=min(TT))
difference=abs(At_minute-TT);
[idx3 idx3]=min(difference);
pHluorinC1atT=pHluorinC1(:,idx3);
pHluorinC1STDatT=pHluorinC1STD(:,idx3);
figure48=figure
plot(pHC1,pHluorinC1atT)
errorbar(pHC1,pHluorinC1atT,pHluorinC1STDatT)
%%
title('Condition 1')
ylabel('Ratio of 395/475 excitation')
xlabel('pH')
SinglePosition=TT(idx3);
potentialString=join(['Time point=',num2str(SinglePosition),' minutes']);
annotation('textbox',[0.153158999192897 0.854818787583294 0.177571428571429 0.0309523809523811],'String',potentialString, 'EdgeColor','none', 'BackgroundColor',[1 1 1])
legend('Ratio of 395/475')
ax13= gca;
end
pHluorinC2=W395C2./W475C2;
pHluorinC2STD=W395C2STD./W475C2STD;
if(At_minute<=max(TT)&&At_minute>=min(TT))
difference=abs(At_minute-TT);
[idx3 idx3]=min(difference);
pHluorinC2atT=pHluorinC2(:,idx3);
pHluorinC2STDatT=pHluorinC2STD(:,idx3);
figure49=figure
plot(pHC2,pHluorinC2atT)
errorbar(pHC2,pHluorinC2atT,pHluorinC2STDatT)
%%
title('Condition 2')
ylabel('Ratio of 395/475 excitation')
xlabel('pH')
SinglePosition=TT(idx3);
potentialString=join(['Time point=',num2str(SinglePosition),' minutes']);
annotation('textbox',[0.153158999192897 0.854818787583294 0.177571428571429 0.0309523809523811],'String',potentialString, 'EdgeColor','none', 'BackgroundColor',[1 1 1])
legend('Ratio of 395/475')
ax14= gca;
end
pHluorinC3=W395C3./W475C3;
pHluorinC3STD=W395C3STD./W475C3STD;
if(At_minute<=max(TT)&&At_minute>=min(TT))
difference=abs(At_minute-TT);
[idx3 idx3]=min(difference);
pHluorinC3atT=pHluorinC3(:,idx3);
pHluorinC3STDatT=pHluorinC3STD(:,idx3);
figure50=figure
plot(pHC3,pHluorinC3atT)
errorbar(pHC3,pHluorinC3atT,pHluorinC3STDatT)
title('Condition 3')
ylabel('Ratio of 395/475 excitation')
xlabel('pH')
SinglePosition=TT(idx3);
potentialString=join(['Time point=',num2str(SinglePosition),' minutes']);
annotation('textbox',[0.153158999192897 0.854818787583294 0.177571428571429 0.0309523809523811],'String',potentialString, 'EdgeColor','none', 'BackgroundColor',[1 1 1])
legend('Ratio of 395/475')
ax15= gca;
end
pHluorinC4=W395C4./W475C4;
pHluorinC4STD=W395C4STD./W475C4STD;
if(At_minute<=max(TT)&&At_minute>=min(TT))
difference=abs(At_minute-TT);
[idx3 idx3]=min(difference);
pHluorinC4atT=pHluorinC4(:,idx3);
pHluorinC4STDatT=pHluorinC4STD(:,idx3);
figure51=figure
plot(pHC4,pHluorinC4atT)
errorbar(pHC4,pHluorinC4atT,pHluorinC4STDatT)
title('Condition 4')
ylabel('Ratio of 395/475 excitation')
xlabel('pH')
SinglePosition=TT(idx3);
potentialString=join(['Time point=',num2str(SinglePosition),' minutes']);
annotation('textbox',[0.153158999192897 0.854818787583294 0.177571428571429 0.0309523809523811],'String',potentialString, 'EdgeColor','none', 'BackgroundColor',[1 1 1])
legend('Ratio of 395/475')
ax16= gca;
end
figure47=figure
s13=subplot(2,2,1);
title('Condition 1')
xlabel('pH')
ylabel ('Ratio of 395/475 excitation')
s14=subplot(2,2,2);
title('Condition 2')
xlabel('pH')
ylabel ('Ratio of 395/475 excitation')
s15=subplot(2,2,3);
title('Condition 3')
xlabel('pH')
ylabel ('Ratio of 395/475 excitation')
s16=subplot(2,2,4);
title('Condition 4')
xlabel('pH')
ylabel ('Ratio of 395/475 excitation')
fig13=get(ax13,'children');
fig14=get(ax14,'children');
fig15=get(ax15,'children');
fig16=get(ax16,'children');
copyobj(fig13,s13);
copyobj(fig14,s14);
copyobj(fig15,s15);
copyobj(fig16,s16);
end
I have only inserted the section where error bars are required, as I don't think the other informaiton is that relevant.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Properties 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by