clf lambda=[579.0 577.0 546.1 496.0 491.6 435.8 407.8 404,7] x=[66.1 66.3 69 75 75.8 85 92.5 93.5] plot(x,lambda,'o') p=polyfit(x,lambda,3) x=55:0.5:100 lambda=polyval(p,x) hold on plot(x,lambda) xlabel('x / arbitrary units') ylabel('\lambda / nm') title('Calibration curve of the spectroscope') xhelium=[63 64.9 70 79 80 83.2 88.1] lambdahelium=polyval(p,xhelium) xneon=[65.9 67.2 69.5 74.2] lambdaneon=polyval(p,xneon)
MATLAB: I have this , and is showing me the vector must be the same lenght plot
errorplot
Related Solutions
So I think this might be what you're looking for. I commented out the 'i' redefinition at the very bottom and added 'figure' but to answer the coloring question I recommend using the mod (for modulus) command. If you specify
color{mod(i-1,4)+1}
the values, for i=1:8 for example, will go:
color{1}color{2}color{3}color{4}color{1}color{2}color{3}color{4}
and the pattern will keep repeating for varying 'i' definitions. Here is the modified code:
AOI=[0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 8 8 8 8 8 8];row1=[35 35 35 35 36 36.5 37 35 37 35 36 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35 35 35 35 35 36 36.5 37 35 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35];col1= [56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47 56 56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47];row2=[35 35 35 35 36 36.5 37 35 37 35 36 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35 35 35 35 35 36 36.5 37 35 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35];col2= [56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47 56 56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47];row3=[35 35 35 35 36 36.5 37 35 37 35 36 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35 35 35 35 35 36 36.5 37 35 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35];col3= [56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47 56 56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47];row4=[25 25 25 25 26 26.5 27 25 27 25 26 27 26 25 27 24 24 25 26 26 26 27 27 27 28 28 24 24 25 25 25 25 25 25 25 25 25 26 26.5 27 25 27 26 25 27 24 24 25 26 26 26 27 27 27 28 28 24 24 25 25 25 25 25];col4= [56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47 56 56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47];row5=[35 35 35 35 36 36.5 37 35 37 35 36 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35 35 35 35 35 36 36.5 37 35 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35];col5= [66 67 67 68 66 67 66 66 66 67 65 65 66 66 66 64 65 65 66 66 67 67 68 68 66 66 65 66 65 66 67 66 66 67 67 68 66 67 66 66 66 67 65 65 66 66 66 64 65 65 66 66 67 67 68 68 66 66 65 66 65 66 67];row6=[35 35 35 35 36 36.5 37 35 37 35 36 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35 35 35 35 35 36 36.5 37 35 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35];col6= [56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47 56 56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47];row7=[35 35 35 35 36 36.5 37 35 37 35 36 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35 35 35 35 35 36 36.5 37 35 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35];col7= [56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47 56 56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47];row8=[2:2:126];col8= [56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47 56 56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47];coord=[2:2:126];times=[1:63];AOI_unique=unique(AOI);num_AOI=length(AOI_unique);colors={'r' 'g' 'b' 'c' };%while num_AOI>length(colors)
figurehplt=plot(times,coord, 'DisplayName', 'coord\_pos\_sibs\_xfpi'); hold on hleg=legend('-DynamicLegend'); set(hleg, 'FontSize',10); grid on datetick('x','HH:MM:SS', 'keeplimits') title('Position of SIBS on FPI') xlim([min(times), max(times)]) xlabel('Time (UT)'); ylabel('Value'); hold onfor i=1:length(AOI_unique) if AOI_unique(i)==1 %%Plot
hplt=plot(times, col1, colors{mod(i-1,4)+1}, 'DisplayName', 'column 1'); hold on hplt=plot(times, row1, 'c--', 'DisplayName', 'row 1'); hold on hleg=legend('-DynamicLegend'); set(hleg, 'FontSize',10); grid on elseif AOI_unique(i)==2 %%Plot hplt=plot(times, col2, colors{mod(i-1,4)+1}, 'DisplayName', 'column 2'); hold on hplt=plot(times, row2, 'g--', 'DisplayName', 'row 2'); hold on hleg=legend('-DynamicLegend'); set(hleg, 'FontSize',10); grid on elseif AOI_unique(i)==3 %%Plot hplt=plot(times, col3, colors{mod(i-1,4)+1}, 'DisplayName', 'column 3'); hold on hplt=plot(times, row3, 'b--', 'DisplayName', 'row 3'); hold on hleg=legend('-DynamicLegend'); grid on elseif AOI_unique(i)==4 %%Plot hplt=plot(times, col4, colors{mod(i-1,4)+1}, 'DisplayName', 'column 4'); hold on hplt=plot(times, row4, 'r--', 'DisplayName', 'row 4'); hold on hleg=legend('-DynamicLegend'); set(hleg, 'FontSize',10); grid on elseif AOI_unique(i)==5 %%Plot hpltA=plot(times, col5, colors{mod(i-1,4)+1}, 'DisplayName', 'column 5'); hold on hplt=plot(times, row5, 'c--', 'DisplayName', 'row 5'); hold on hleg=legend('-DynamicLegend'); set(hleg, 'FontSize',10); grid on elseif AOI_unique(i)==6 %%Plot hplt=plot(times, col6, colors{mod(i-1,4)+1}, 'DisplayName', 'column 6'); hold on hpltA=plot(times, row6, 'g--', 'DisplayName', 'row 6'); hold on hleg=legend('-DynamicLegend'); set(hleg, 'FontSize',10); grid on elseif AOI_unique(i)==7 %%Plot hplt=plot(times, col7, colors{mod(i-1,4)+1}, 'DisplayName', 'column 7'); hold on hplt=plot(times, row7, 'b--', 'DisplayName', 'row 7'); hold on hleg=legend('-DynamicLegend'); set(hleg, 'FontSize',10); grid on elseif AOI_unique(i)==8 %%Plot hplt=plot(times, col8, colors{mod(i-1,4)+1}, 'DisplayName', 'column 8'); hold on hplt=plot(times, row8, 'r--', 'DisplayName', 'row 8'); hold on hleg=legend('-DynamicLegend'); set(hleg, 'FontSize',10); grid on end% i=i+1;
end
gama_rd=50;v = 0.1;lambda=0:.01:100*.01;fi=((lambda*v*gama_rd+lambda*v+2-lambda).*(1-lambda))./((lambda*v+2-lambda).*(lambda*v+1-lambda));plot(lambda,fi)
Best Answer