how can I have a single number as the result of dividing two numbers?

9 ビュー (過去 30 日間)
2NOR_Kh
2NOR_Kh 2022 年 8 月 22 日
コメント済み: 2NOR_Kh 2022 年 8 月 23 日
I am implementing this formula in MATLAB:
I[i], is the intensity of my signal and i is the index for each row. My code is as follow:
I attached my signal to this message.
Based on the formula, each time for specific i, I should have a number and then put it in the ith u. but in my code the result of the division is a matrix each time(xc(:,i)./diff((accum))) and I have no idea how to fix it.
M1=length(xc);
accum1=zeros(M1,1);
accum=zeros(M1+1,1);
a=zeros(1,N);
N=200;
for i=1:N
for j=i:N
accum1=accum1+(xc(:,j));
end
accum(1:M1) = accum1;
a(1,i)=xc(:,i)./(2*diff((accum)));
accum1=zeros(M1,1);
accum=zeros(M1+1,1);
end
  2 件のコメント
Chunru
Chunru 2022 年 8 月 23 日
Can you explain the meaning of Δ in your formula?
It seems that the use of "diff" to accum produces a vector rather than a scalar.
2NOR_Kh
2NOR_Kh 2022 年 8 月 23 日
編集済み: 2NOR_Kh 2022 年 8 月 23 日
this is the definition:
"measurements of I[i] are given by the integrated signal over a small distance, defined by the pixel size Δ and commonly related to the coherence length of the light source"
so I get that "small distance" or saying Δ as diiferentiate function.
But, now that I am thinking, my implementation is not correct. It is saying that delta or Δ is the pixel size, I am not working with pixels but does it mean that this delta is a constant?

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

回答 (2 件)

Image Analyst
Image Analyst 2022 年 8 月 23 日
編集済み: Image Analyst 2022 年 8 月 23 日
Try this:
s = load('matlab.mat')
xc = s.xc;
[rows, columns] = size(xc)
subplot(2, 2, 1);
imshow(xc, []);
subplot(2, 2, 2);
hold on;
grid on;
for col = 1 : columns
plot(xc(:, col), '-', 'LineWidth', 1);
end
delta = 2; % Whatever it is....
% Compute u for each column.
sumi = cumsum(xc);
for col = 1 : columns
u = zeros(rows, 1);
% Reinitialize
for i = 1 : rows
% Compute sum from i+1 to the end
theSum = sumi(end, col) - sumi(i, col);
u(i) = xc(i) / (2 * delta * theSum);
end
subplot(2, 2, 3:4);
plot(u, '-')
hold on
end
grid on;
  1 件のコメント
2NOR_Kh
2NOR_Kh 2022 年 8 月 23 日
the results should be something like (b):
However, maybe somewhere I forgot something.
This formula and figure are from this refrence:
Depth-resolved model-based reconstruction of attenuation coefficients in optical coherence tomography

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


Chunru
Chunru 2022 年 8 月 23 日
編集済み: Chunru 2022 年 8 月 23 日
load(websave("matalb.mat", "https://www.mathworks.com/matlabcentral/answers/uploaded_files/1104765/matlab.mat"));
[M1, N] = size(xc);
delta = 1;
% The formula is not well defined for i=M1
% The summation in denominator can be computed using cumsum for efficiency
den = cumsum(flipud(xc(2:end, :)));
a = xc(1:M1-1, :)./(delta*den(end:-1:1, :));
plot(xc(:, 1)); hold on
plot(a(:, 1))

カテゴリ

Help Center および File ExchangeArray Geometries and Analysis についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by