To RESHAP the number of elements must not change.
1 view (last 30 days)
Show older comments
I got an error while compile the following code To RESHAP the number of elements must not change.
code:
[Result,pData,DataCapture] = AO_GetChannelData(11016);% Analog input_current measure
line
%plot(pData)
pData_res=reshape(pData(1:DataCapture),[pData(1),DataCapture/pData(1)]);
pData_clean=pData_res(8:pData(1),:);
pData_new=(reshape(pData_clean,[1,length(pData_clean)*16]))*(10000/2^12);
plot(1/2750:1/2750:(length(pData_new))/2750,pData_new)
axis([0 0.12 -200 3000])
0 Comments
Answers (1)
Walter Roberson
on 20 Jan 2016
p1 = double(pdata(1));
dc = double(DataCapture);
if mod(dc, p1) ~= 0
error(sprintf('DataCapture, %g is not evenly divisible by %g', p1, dc));
end
pData_res = reshape(pData(1:DataCapture), [p1, dc]);
I believe if you check you will find that class(pdata) is uint8 and that DataCapture/pdata(1) would be greater than 255 but is being truncated at 255. For example,
(72 * 2131) == 153432
is true (the division is exact), but
153432 / uint8(72)
is uint8(255) instead of 2131, because of the way that operations are carried out when you are working with an integer data class.
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!