Dimensional error while running the code from matlab documentation
조회 수: 12 (최근 30일)
이전 댓글 표시
fs = 1e3;
t = 0:1/fs:1;
x = [2 1 2]*sin(2*pi*[50 150 250]'.*t) + randn(size(t))/10;
in this code the dimension of the t mismatches with [50 150 200]'. how could i possibly get the output without dimesnsional error?
댓글 수: 0
채택된 답변
Tommy
2020년 4월 17일
This code should run without error in R2016b and later due to implicit expansion, as t is a row vector and [50 150 200]' is a column vector. This is similar to
>> [1;2].*[1:10]
ans =
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
which might also be expected to result in an error.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!