Finding the Power density function
조회 수: 4 (최근 30일)
이전 댓글 표시
I am trying to find the power density function of the 8 datasets, attached below. Can anyone help me?
댓글 수: 3
Hiro Yoshino
2021년 2월 3일
Basic approach could be FFT.
Also if you have any question on your code, you should use code format from the tooltip like this:
a = 1
b = 2
x = 1:10
y = sin(a*x)
답변 (1개)
Vidhi Agarwal
2024년 5월 21일
Hi Christina Reid,
I understand that you are not getting expected output while printing columns of dataset. This is happening because of the following reasons:
- This loop, due to its condition “i = size(dataset,2)”, does not actually loop in the traditional sense. It sets “i" to the number of columns in dataset and then runs the body of the loop once with “i” being that value. If dataset initially has 8 columns, “i" is set to 8.
- “col(:,i) = dataset(:,i)” attempts to copy the i-th column of dataset into “col”. However, since “i” is only the last column's index due to the loop's setup, this operation only copies the last column.
To enhance the code and avoid the unintended redefinition of "dataset" inside the loop, you should move the construction of the "dataset" matrix outside and before the loop. This ensures that "dataset" is defined only once, and the loop is then used solely for processing each column of this dataset.
Modified Code of “for” loop will look like:
dataset = [data1,data2, data3, data4, data5, data6, data7,data8];
for i = 1:size(dataset,2)
col(:,i) = dataset(:,i)
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!