How can I generate a code for this equation?

조회 수: 1 (최근 30일)
FSh
FSh 2019년 6월 10일
댓글: FSh 2019년 6월 11일
compute this formula

채택된 답변

Manvi Goel
Manvi Goel 2019년 6월 10일
You can use the following code for this
a = [429.494, 93.112, -6.050];
N = 1024;
temp = 0;
lambda = zeros(1, N)
for i = 1:N
for j = 1:3;
temp = temp + (a(j) * (((i - 1) / N - 1) ^ (j - 1)));
end
lambda(i) = temp;
temp = 0;
end
The lambda array will contain the final values.

추가 답변 (1개)

Raj
Raj 2019년 6월 10일
If you have Symbolic math toolbox then this can be done in an elegant way. In case you don't have symbolic math toolbox (like me) this code will do:
N=1024;
a=[429.494;93.112;-6.050];
wavelength=zeros(N,1);
for m=1:N
temp=zeros(3,1);
for n=1:3
temp(n,1)=a(n,1)*(((m-1)/(N-1))^(n-1));
end
wavelength(m,1)=sum(temp);
end
  댓글 수: 4
madhan ravi
madhan ravi 2019년 6월 11일
It’s a homework obviously.
FSh
FSh 2019년 6월 11일
Dimensions of arrays being concatenated are not consistent.
This is the error. not homework, that is a part of my data analysis.

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

Community Treasure Hunt

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

Start Hunting!

Translated by