フィルターのクリア

Plotting a diagram and getting some errors

2 ビュー (過去 30 日間)
Oskar S.
Oskar S. 2024 年 4 月 23 日
コメント済み: Oskar S. 2024 年 4 月 23 日
Hi, I'm having an issue with my code. I'm trying to plot a basic diagram, but MATLAB is only giving me errors.Error massage is "
Undefined function 'plotv' for input arguments of type 'double'." I'm wondering where I might be going wrong. My code looks like this:
x_1 = [-0.9487 ; 0.3162];
x_2 = [-0.2425 ; -0.9701];
u = x_1 + x_2;
A_u = A .* u;
A_2u = A^2 * u;
hold on
plotv(x_1,'r');
plotv(x_2,'b');
plotv(u,'k');
plotv(A_u,'g');
plotv(A_2u,'c');
legend('x1','x2', 'u', 'Au', 'A^2u');
hold off

採用された回答

VBBV
VBBV 2024 年 4 月 23 日
編集済み: VBBV 2024 年 4 月 23 日
There is no function called plotv in Matlab (or it must have been removed in new release), Please refer to the following link for plotting 2D graphs. Or use plotvec if you want to plot vectors
x_1 = [-0.9487 ; 0.3162];
x_2 = [-0.2425 ; -0.9701];
u = x_1 + x_2;
A = randi([1 10]);
A_u = A .* u;
A_2u = A.^2 .* u;
hold on
plotvec(x_1,randi([0 4],1,4));
plotvec(x_2,randi([0 4],1,4));
plotvec(u,randi([0 4],1,4));
plotvec(A_u,randi([0 4],1,4));
plotvec(A_2u,randi([0 4],1,4));grid
legend('x1','x2', 'u', 'Au', 'A^2u');
hold off
  3 件のコメント
VBBV
VBBV 2024 年 4 月 23 日
編集済み: VBBV 2024 年 4 月 23 日
If you want to plot vectors its better to use quiver, and apply your function
[X,Y] = meshgrid(linspace(-0.9487, 0.3162,10),linspace(-0.9701,-0.2425,10));
U = X+Y;
A = randi([1 10]).*U;
A2u = A.^2.*U;
hold on
quiver(X,Y,U,A,.5)
quiver(X,Y,U,A2u,1)
Oskar S.
Oskar S. 2024 年 4 月 23 日
thank you very much

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by