Can someone explain what's wrong with my formula?
1 回表示 (過去 30 日間)
古いコメントを表示
close all
clear
clc
syms t
omega = 2:2:6
I = 10
C = 0.05
V = (-I./omega.*C)*cos(omega.*t)
fplot(V)
What is wrong with it? I get an error when I try to run it.
0 件のコメント
採用された回答
その他の回答 (1 件)
Walter Roberson
2021 年 9 月 30 日
omega is a vector, so (-I./omega.*C) is a vector and cos(omega.*t) is a vector the same size.
So you have 1 x 3 row vector * 1 x 3 row vector. But the * operator is algebraic matrix multiplication, "inner product". In the expresson A*B then size(A,2) must equal size(B,1) -- the "inner" dimensions must match. The first 1 x 3 vector operand for the * operation has 3 columns. The second 1 x 3 vector operand for the * operation has 1 row. But 1 is not equal to 3, so the * operation fails.
The element-by-element multiplication operator is .* instead of *
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!