How can I generate a code for this equation?
2 ビュー (過去 30 日間)
古いコメントを表示
compute this formula
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/223769/image.png)
0 件のコメント
採用された回答
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.
0 件のコメント
その他の回答 (1 件)
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 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!