Error message: Matrix Dimensions must agree
16 ビュー (過去 30 日間)
古いコメントを表示
Not sure what I am doing wrong:
syms x
n = 0:1:100;
t = 0:0.1:50;
lamda = (n .* pi);
u = (100 .* cosd(lamda .* x) + (sind(lamda .* x)) .* (exp((-lamda .^ 2) .* t) ;
fplot(t,u)
grid on
Thank you
0 件のコメント
回答 (2 件)
Vinay
2025 年 1 月 29 日 10:33
The issue arises due to mismatch in matrix dimensions between "exp((-lambda .^ 2))" and "t", which are of sizes "1x101" and "1x501", respectively.
To resolve this issue, adjust the dimensions of the vector "t" to 1x101. This can be achieved by modifying the definition of t as follows:
t = 0:0.5:50;
I hope this resolves the query!
0 件のコメント
VBBV
2025 年 2 月 3 日 15:23
- Use linspace to divide the data points uniformly for variables in the equation.
- use a function handle, when plotting function fplot
- Ensure the parenthesis are closed correctly
n = linspace(0,100,10);
t = linspace(0,50,10);
lamda = (n .* pi);
u = @(x) 100 .* cosd(lamda .* x) + (sind(lamda .* x) .* exp((-lamda .^ 2) .* t)) ;
fplot(u,[0 1])
grid on
1 件のコメント
Walter Roberson
2025 年 2 月 3 日 20:31
use a function handle, when plotting function fplot
There are two different fplot() functions, one of which is defined for function handles, and the other (closely related) one is defined for symbolic expressions and symbolic functions. In theory, using fplot() with symbolic expressions should be fine, if a bit slower than the function handle case.
参考
カテゴリ
Help Center および File Exchange で Number Theory についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!