I am creating a desgin matrix for a data set and I have this equation
y(t)=a1 + a2 exp(-(t-0.0001)/50^2) + a3 sin(2π(60)t)
When I am entering it into matlab I keep getting error and I don't know what I am doing wrong.
Code:
X=(2*pi*(60)*t);
A = [ones(length(t),1) exp(-((t-0.0001)/50).^2)' sin(2*pi*(60)*t)];
Output:
Error using horzcat
Dimensions of arrays being concatenated are not consistent.

댓글 수: 4

Try running it again as so:
clear all
t = 5;
X=(2*pi*(60)*t);
A = [ones(length(t),1) exp(-((t-0.0001)/50).^2)' sin(2*pi*(60)*t)];
I dont see any issues so perhaps you have over written some variable somehwere or is t an array / vector of values?
Walter Roberson
Walter Roberson 2019년 3월 21일
The code assumes that t is a column vector and will fail if it is a row vector.
Emilee Burris
Emilee Burris 2019년 3월 23일
t is a vector of values
Before the assignment to X, insert
t = t(:);
That should fix the problem.

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

태그

질문:

2019년 3월 21일

댓글:

2019년 3월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by