How to use for loop to generate spectral line

조회 수: 2 (최근 30일)
Mohamad Khairul Ikhwan Zulkarnain
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
I just explaining the situation. The thing that i cant get is how should I create a spectral line with many peak?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Polar Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by