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

조회 수: 8 (최근 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 CenterFile Exchange에서 Array 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