フィルターのクリア

Error in the script

1 回表示 (過去 30 日間)
Haowei Zhang
Haowei Zhang 2022 年 11 月 23 日
コメント済み: Haowei Zhang 2022 年 11 月 23 日
I was creating a graph where the system says "Variable y_div must be of size [1 2001]. It is currently of size [1 1]. Check where the variable is assigned a value."
Idk whats wrong
x = -1 : 0.001 : 1;
y_div = (x.^2) / (1 + (x.^2));
title ('División acotada');
plot (x, y_div);
subplot (3,1,1);

採用された回答

Walter Roberson
Walter Roberson 2022 年 11 月 23 日
A/B is approximately A*pinv(B) where the * is inner product (algebraic matrix multiplication). When both sides are column vectors the result is a scalar.
You need the division operator, which is ./ not /

その他の回答 (2 件)

Torsten
Torsten 2022 年 11 月 23 日
x = -1 : 0.001 : 1;
y_div = (x.^2) ./ (1 + (x.^2));
title ('División acotada');
plot (x, y_div);

Carlos Guerrero García
Carlos Guerrero García 2022 年 11 月 23 日
If you put the title and then plot without "hold on" you never see the title (swap title and plot instructions), but your error is the dot before "/". Try with the following lines:
In Spanish: Si pones el título antes de "plot" sin poner "hold on" entonces no te aparecerá el título. Para arreglar eso, te propongo hacer primero "plot" y luego poner el título, pero tu error está en el punto antes de la división. Prueba con lo siguiente:
x = -1:0.001:1;
y_div =(x.^2)./(1+(x.^2));
plot(x, y_div);
title('División acotada')
  2 件のコメント
Carlos Guerrero García
Carlos Guerrero García 2022 年 11 月 23 日
I thnik you're showing that the function f(x)=x^2/(1+x^2) is a bounded one. If I'm right, I suggest the usage of a bigger interval. Perhaps [-10,10] will be better than [-1,1]. I suggest the following lines:
x = -10:0.001:10;
y_div =(x.^2)./(1+(x.^2));
plot(x, y_div);
title('División acotada')
Haowei Zhang
Haowei Zhang 2022 年 11 月 23 日
Gracias, es que lo sabia hacer esto pero de repente se me olvido de eso xD.

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

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by