フィルターのクリア

I am working on homework but i cannot figure out what is wrong

1 回表示 (過去 30 日間)
Jaeyoung Lee
Jaeyoung Lee 2019 年 3 月 1 日
コメント済み: Walter Roberson 2019 年 3 月 1 日
F = kx where F is the force in newtons and k is the spring constant in newtons per meter. The potential energy stored in the compressed spring is gived by E = 1 2 kx2 where E is the energy in joules. Plot energy E as a function of x (x ∈ [0, 10]) for two different spring constants k = 20N/m, 40N/m . Requirements are as follows: 1. Use different lines and markers for different k values(5 points). 2. Have labels on both axes (4 points), legends for different k values (4 points). 3. Use proper font size, line width and marker size (4 points). 4. In the PDF document, have a caption describing the figure (3 points) ------R2016b-----
x = [0: 1: 10];
k = [20 40];
F = k.* x
E = 0.5*k.*x.^2
I know how to plot and do other following things.
But i have no idea how to make this right
  2 件のコメント
madhan ravi
madhan ravi 2019 年 3 月 1 日
what do you mean by right ?
Jaeyoung Lee
Jaeyoung Lee 2019 年 3 月 1 日
Matrix dimensions must agree.
Error in untitled2 (line 4)
F = k.* x
keep getting this

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

回答 (2 件)

Walter Roberson
Walter Roberson 2019 年 3 月 1 日
編集済み: Walter Roberson 2019 年 3 月 1 日
Use
x = linspace(0,10).';
Provided you are using R2016b or later.
  2 件のコメント
Jaeyoung Lee
Jaeyoung Lee 2019 年 3 月 1 日
Would you please solve this question for me?
I just started to learn this and not sure where to begin..
Walter Roberson
Walter Roberson 2019 年 3 月 1 日
h = plot(x,E)
h will be a vector of two line() objects. Set their properties appropriately.

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


RAMAKANT SHAKYA
RAMAKANT SHAKYA 2019 年 3 月 1 日
編集済み: RAMAKANT SHAKYA 2019 年 3 月 1 日
whenever you do array multiplication the no of elements in both array must be same or multiply with a constt number with array or matrix. this is the error is here but i can't give you exact answer you this question is the part of your homework .so i suggest you that make two case for the two value of spring constant.
in first case take value of k=20; than after do array multiplication it is the simply constt multiplication in to matrix
like
x=0:10;
k=20;
f=k.*x;
and soon on. i hope this will help you
  4 件のコメント
Jaeyoung Lee
Jaeyoung Lee 2019 年 3 月 1 日
How about graph?
Do i simply write plot (x1,k1) and (x2 k2)?
RAMAKANT SHAKYA
RAMAKANT SHAKYA 2019 年 3 月 1 日
no you can plot by writing
plot(x,F1) and plot(x,E1) for first case and similarly for second by F2 and E2 in the place of f1 and e1. to plot on same graph use hold on or any other fuction according to your requirement.

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

カテゴリ

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