TASK Create a variable volumes that contains the last two columns of data. You can see the size of data in the output pane to the right of your screen.
조회 수: 17 (최근 30일)
이전 댓글 표시
and i wrote volumes = data(:,3:4) is still giving me error
댓글 수: 2
John D'Errico
2023년 5월 30일
편집: John D'Errico
2023년 5월 30일
The line you wrote SHOULD put columns 3 and 4 into the array volumes. That it generates an error just means you did something we are not told.
When you get an error, show the ENTIRE error. Don't just tell us that something is still giving an error. We cannot see your screen, and we certainly cannot see into your computer.
Paste in the error message, the ENTIRE error message. So everything in red.
답변 (1개)
Image Analyst
2023년 5월 30일
편집: DGM
2024년 10월 29일
Is data a 3-D array? What does this show"
whos data
If data is a 3-D array you need to do
volumes = data(:, 3:4, :)
If data is a 2-D array, then your code would have worked.
댓글 수: 1
DGM
2024년 10월 29일
FWIW, the exercise uses a 7x4 array. The evaluator will accept anything which produces the expected output, so
% the given answer works fine
volumes = data(:, 3:4)
will work, just the same as anything equivalent for the given input:
% the intended answer
volumes = data(:, end-1:end)
% it's not necessary, but these are also accepted
volumes = data(:, 3:4, :)
volumes = data(:, end-1:end, :)
% so is something unnecessarily complicated
col = size(data,2) + [-1 0];
volumes = data(:,col)
I did actually test those.
I'm with John on this one. There is (was) something else going on. It might not even be an issue with the code at all, so I don't expect that any error message actually occurs in the editor. I know the onramp interface bugs out sometimes and refuses to accept correct answers. I had to reload it a couple times before it would even let me type in the editor, and it doesn't even load at all in Firefox anymore, so maybe reloading or trying a different browser is at least an attempt at troubleshooting.
참고 항목
카테고리
Help Center 및 File Exchange에서 Whos에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!