error for incorrect dimensions

11 ビュー (過去 30 日間)
John Cartwright
John Cartwright 2019 年 4 月 5 日
回答済み: Walter Roberson 2019 年 4 月 5 日
When I run this script I get an error that says that I have incorrect dimensions for matrix multiplication. I want it to run through all of the values for t and produce a array with the values for v. I have used this same format for similar problems and have never gotten an error.

回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 4 月 5 日
You have something of generally the form exp(t) * cos(t) . That * operation is algebraic matrix multiplication, which can only work if the second dimension of the first argument (so, length(t) in this case) is the same as the first dimension of the second argument (which would be 1 in this case, since cos(t) would be a 1 x something vector.)
You should probably be using .* operator instead of the * operator.

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by