I would be very thankful if someone help me
Modifying a code (code by Mohammad alshikh khalil)
2 views (last 30 days)
Show older comments
Jackol Jackil on 2 May 2015
Answered: Nalini Vishnoi on 6 May 2015
Hi, I am trying to modify the following code to plot (lambdas, ans) where lambdas sis the wavelength range that I give as input and and is the results of the code. To run the code inputs need to be: coeffs [1.0792 6.0840 0.2822 1.900 27.62] and Lambdas range should be from 850 to 1500. when I use plot command, I get an error says the vector must be the same length. error: Error using plot Vectors must be the same lengths.
Error in sel (line 19)
plot (Lambdas, nn)
here is the code:
function nn = sel (coeffs, x )
%sel Calculate sellmier eqs
% n(l)^2 = A + c1*(x^2)/(x^2-L1^2) + c2*(x^2)/(x^2-L2^2) + ...,
% where x is the wavelength,
%A is the offset
% c1,c2,...,cN are the N Sellmeier coefficients
% L1,L2,...,LN are the n Sellmeier coefficients.
coeff=coeffs(2:2:end); % even numbers
Nalini Vishnoi on 6 May 2015
Assuming that you are using the following code:
>> coeffs = [1.0792 6.0840 0.2822 1.900 27.62];
>> x = 850:1500;
>> sel(coeffs, x);
and using a
command inside the 'sel' function, I see that size of Lambdas is 1x2 and size of nn is 1x651. plot command needs the two vectors which are to be plotted to be of the same size. Since they are of different size in this case, hence the error is generated. Did you want to pass 'x' as x = [850 1500]; instead?
Find more on Line 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!