Convolution built-in function

조회 수: 10 (최근 30일)
abdou sakr
abdou sakr 2017년 4월 19일
편집: dpb 2017년 4월 20일
What are conv function updates as I can't run this code conv(RC,plot(amp)) without error Error: using conv2 Invalid data type. First and second arguments must be numeric or logical., Thing do not happen in version 13 !!
  댓글 수: 3
abdou sakr
abdou sakr 2017년 4월 19일
편집: abdou sakr 2017년 4월 19일
that is the script and error only for my updated version
John D'Errico
John D'Errico 2017년 4월 19일
That would not have worked in any rational way in version 13 either. plot will return a handle to the plot, so totally useless in terms of any convolution.

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

채택된 답변

dpb
dpb 2017년 4월 19일
편집: dpb 2017년 4월 20일
What John and Stephen said. What you appear to want (and wanted originally) is just
synthetic=conv(RC,amp);
which would be the convolution of RC and the amp kernel.
Prior to HG2 (handle graphics 2), graphics and other handles were just numeric values (doubles) so arithmetic operations on them were not illegal and so you didn't get an error in earlier release but the answer was nonsensical. Now, handles are a new class and so such erroneous operations can be flagged as errors.
You will want to revisit any calculations done earlier as they are in error; the result would have been just a constant times the vector.
R2012b
>> h=plot(rand(4,1))
h =
174.0016
>> whos h
Name Size Bytes Class Attributes
h 1x1 8 double
>> conv(h,1:4)
ans =
174.0016 348.0032 522.0048 696.0063
>> [1:4]*h
ans =
174.0016 348.0032 522.0048 696.0063
>>
R2014b
>> h=plot(rand(3,1))
>> h
h =
Line with properties:
...
>> whos h
Name Size Bytes Class Attributes
h 1x1 60 matlab.graphics.chart.primitive.Line
>>
>> double(h)
ans =
1.2207e-04
>>
So, you see that prior to HG2 plot returned a double that was a floating point value; the specific value is dependent upon each invocation, but 175+/- is typical. OTOH, with HG2 as R2014b shows, the handle is a class variable and you can't see the numeric value unless you cast it to double and you see the numeric value is grossly different.
Either, way, using the line handle in conv makes no sense computationally, whatsoever.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by