How can I write this C++ script to Matlab?

조회 수: 1 (최근 30일)
onamaewa
onamaewa 2019년 2월 15일
답변: Walter Roberson 2019년 2월 15일
How would you write this C++ script to Matlab?
do k = No_TimeSamples
do i = No_Pixels
SUM_1 = 0
SUM_2 = 0
do j = 1, No_Geophones
delay = R(i, j)/c
ik = round(delay/dt + k)
SUM_1 = SUM_1 + Data(ik, j)
SUM_2 = SUM_2 + Data(ik, j)**2
end
image(i) = image(i) + SUM_1**2 - SUM_2
end
end
  댓글 수: 2
Walter Roberson
Walter Roberson 2019년 2월 15일
편집: Walter Roberson 2019년 2월 15일
?
That is not C++. It looks like Fortran to me.
Is No_TimeSamples a vector? Should we assume that k is to assume each value stored in No_TimeSamples in turn? Or should we assume that k is to assume only the one value stored in No_TimeSamples? Or should we assume that k is to assume the values from 1 to No_TimeSamples ?
Are you certain that the lower bound for the do j loop should be lower-case L, and not i or 1 ?
onamaewa
onamaewa 2019년 2월 15일
It is a vector.
I have a CSV read into matlab with 10 000 time points, & 32 Sensor Channels.
This code generates an image based on data.
R(i, j) is an array.
Data(ik, j) is an array generated from my csv.
image(i) stores the values that generate the image.

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

답변 (1개)

Walter Roberson
Walter Roberson 2019년 2월 15일
for k = No_TimeSamples
for i = No_Pixels
SUM_1 = 0;
SUM_2 = 0;
for j = 1 : No_Geophones
delay = R(i, j)/c;
ik = round(delay/dt + k);
SUM_1 = SUM_1 + Data(ik, j);
SUM_2 = SUM_2 + Data(ik, j).^2;
end
image(i) = image(i) + SUM_1.^2 - SUM_2;
end
end
Note: naming a variable image is not recommended, as it interferes with using the image() display function and confuses readers.

카테고리

Help CenterFile Exchange에서 Point Cloud Processing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by