How to use for loop to generate spectral line

2 ビュー (過去 30 日間)
Mohamad Khairul Ikhwan Zulkarnain
Mohamad Khairul Ikhwan Zulkarnain 2018 年 8 月 28 日
Hi guys, I already created a code to put all my data in one array which is shown below:
% creating a multidimensional array
files = dir('*txt') ; % you are in the folder with text files
N = length(files) ;
names = {files(:).name}' ;
iwant = cell(N,1) ;
for i = 1:N
iwant{i} = importdata(files(i).name) ;
end
And from that data I able to create 20 more new wavelength from any element that i chose and the code is in different file and it shown below:
A = input('Please enter an element in form of iwant{i}:');
% find the number of samples
n = length (A(:,1));
% step change for the wavelength
step = 0.02;
% wavelength which is at the centre
p = A(:,1);
% to make new wavelength for each of wavelength in the samples
for j=1:n
new_wavelength(j,:) = p(j)-step*10:step:p(j)+step*10;
end
format shortG
Now from the data created i need to make a spectral line. I be able to create one peak from each row present in the new wavelength code but when I want to make two or more peak (which is more than one row selected) I cant make it and it give me the result which will be attached and the coding for it is as below:
j = input('Please input the row:');
i = input('Please input number for element:');
Delta_lambda=0.2
int_fact= 0.00001.*iwant{i}(j,2)
denominator = Delta_lambda/2; % this is a constant
K=21; % the upper limit of the loop magic number
numerator = new_wavelength(j,11)-new_wavelength(j,1:K); % vectorize to have 21 elements
Peak_1 = int_fact.*1./(1+(numerator/denominator).^2);
hold on
plot(new_wavelength(j,:),Peak_1,'g')
Is there any way for me to make more than one peak in one plot. maybe using for loop will work but I dont know how to do it bcs I try numerous time and it still wont work and it kept giving me dimension mismatch.
  2 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 8 月 28 日
The question should be concise.
Mohamad Khairul Ikhwan Zulkarnain
Mohamad Khairul Ikhwan Zulkarnain 2018 年 8 月 28 日
I just explaining the situation. The thing that i cant get is how should I create a spectral line with many peak?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangePolar Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by