I need help to solve this plot:
syms X L
X = 0:L/16:L;
Y = 1 + 2*X;
plot (X,Y);
This is just an example, the function I am trying to solve is a bit complicated.

 採用された回答

Walter Roberson
Walter Roberson 2021 年 4 月 17 日

0 投票

In this particular case, you can plot something meaningful. In most cases, you cannot plot with unresolved symbolic variables unless you use fplot() or fplot3() or fsurf() to have MATLAB automatically substitute specific numeric values for the unresolved values.
You cannot, for example, plot a family of curves expecting it to show you abstract curves such as "s", "s/2", "s/4", "3s/2" and so on. Plotting always requires that something replaces all symbolic variables with particular numeric values.
syms X L
X = 0:L/16:L;
Y = 1 + 2*X;
fplot3(L, X, Y, [0 20]); xlabel('L'); ylabel('X'); zlabel('Y');

5 件のコメント

Tiago Araujo
Tiago Araujo 2021 年 4 月 17 日
Is it possible to get something like this image?
Walter Roberson
Walter Roberson 2021 年 4 月 18 日
You can get it to draw nearly anything you want, if you put enough effort into it, since you can program in straight lines and curves.
However, to get a diagram such as that, you would still need to plot with specific numeric values, and then label with text.
There is no possibility that MATLAB will automatically draw a diagram such as that on your behalf, with symbolic labels. You would have to tell it something like to use L = 10 for the purpose of drawing, but then tell it to use ytick([0 10]); yticklabel({'0', 'L'})
Tiago Araujo
Tiago Araujo 2021 年 4 月 18 日
How can I fix it?
clear all; clc;
syms X L
X = 0:L/16:L;
Y = 1 + 2*(X/L);
figure
fplot(Y,[0 1]);
I need to plot Y(X) between 0 and 1, in my real problem it doesnt work to assign value to L...
I paste an example from my teacher, i would like to do something like that...
I also tried this:
clear all; clc;
syms X L
X = 0:L/16:L;
for i=1:length(X)
Y(i) = 1 + 2*(X(i)/L);
end
figure
fplot(Y(X),[0 1]);
But it doesnt work.
Walter Roberson
Walter Roberson 2021 年 4 月 18 日
編集済み: Walter Roberson 2021 年 4 月 18 日
syms X L
X = 0:L/16:L;
for i=1:length(X)
Y(i) = 1 + 2*(X(i)/L);
end
figure
plot(X/L, Y);
xticklabels(string(sym(xticks)) + " L")
Tiago Araujo
Tiago Araujo 2021 年 4 月 19 日
Great man, you are great!!!
THANKS!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by