Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Problems in accessing 2nd column of matrix
조회 수: 1 (최근 30일)
이전 댓글 표시
I know this is a very simple problem, but I cant seem to find what is the issue as it seems logical.
I tried instances when xx is a column vector or horizontal vector, but it doesnt make a difference.
Count is the final number of data points i want to obtain. E.g.
count = 10
for k = 1:(length(xx)-1)
temp = *data* (xx(k):xx(k+1));
mat(:,k) = interrp(temp, count);
end
interrp is a function that was written to use the i
interp1 function to use the method 'spline'.
My code always stop after finishing filling up the 1st column. This is the error that I receive: Subscripted assignment dimension mismatch.
답변 (2개)
Geoff Hayes
2015년 4월 11일
편집: Geoff Hayes
2015년 4월 11일
Mich - what are the dimensions of the array that the interrp function is returning? The error message Subscripted assignment dimension mismatch typically means that the code is trying to insert more data than it can fit into the destination array. For example,
x = zeros(3,42);
x(:,2) = randi(255,4,1);
returns the same error because I am trying to assign a 4x1 matrix into a 3x1 destination. Put a breakpoint at the line
mat(:,k) = interrp(temp, count);
then run your code and verify that what interrp is returning is too large for the mat(:,k) destination.
You may also want to pre-size mat prior to entering the for loop so that you know exactly what you are trying (and what you are able) to assign to this matrix.
댓글 수: 2
Geoff Hayes
2015년 4월 11일
Mich - see http://blogs.mathworks.com/videos/2010/09/02/using-debugger-to-walk-through-code to step through the code using the debugger.
pfb
2015년 4월 11일
편집: pfb
2015년 4월 11일
Hi,
Your code is very obscure. What exactly do you want do attain? In particular, this line
temp = xx(xx(k):xx(k+1));
looks weird, especially if xx does not contain positive integers. Even in that case, I kind of see why matlab complains about the dimension mismatch. What is xx?
댓글 수: 1
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!