Question about plotting/vectors

1 回表示 (過去 30 日間)
Ivan
Ivan 2018 年 1 月 10 日
コメント済み: Ivan 2018 年 1 月 10 日
Hey guys, sorry for asking probably completely noob question here, but I actually need help asap. So I'm supposed to do some basic graphs about strains, and I have my formulae which I wrote in the matlab. My sigmax strain for y=0 and for x=-5 (or 5, it's actually radius of a circle) should be 0, and my function gives that result. Since I wanted to plot of it, I just put x=-5:0.01:5 but then my results are completely different. I'm pretty sure I'm just an idiot but I'm still a complete newbie at this program. Anyway here's the code:
if true
R=5;
F=100;
x=-5 %the part I'm having problem with, if I put x=-5:0.01:5, my sigmax doesn't go from 0 to 0
y=0
K=(x.^2+(R-y)^2).^2.*(x.^2+(R+y)^2).^2;
C=x.^4+(R^2-y^2)*(R^2+3*y^2+2.*x.^2);
sigmax=(F/(pi*R))-((4*F*R.*x.^2)/(pi.*K))*C
end

採用された回答

Thorsten
Thorsten 2018 年 1 月 10 日
When x is a vector you have to use element-wise multiplication and division
sigmax=(F/(pi*R))-((4*F*R.*x.^2)./(pi.*K)).*C
  1 件のコメント
Ivan
Ivan 2018 年 1 月 10 日
Ugh I feel even worse now, I'm actually blind af. Thank you for the help :)

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

その他の回答 (1 件)

Birdman
Birdman 2018 年 1 月 10 日
編集済み: Birdman 2018 年 1 月 10 日
R=5;
F=100;
x=-5:0.01:5; %the part I'm having problem with, if I put x=-5:0.01:5, my sigmax doesn't go from 0 to 0
y=0;
K=(x.^2+(R-y)^2).^2.*(x.^2+(R+y)^2).^2;
C=x.^4+(R^2-y^2)*(R^2+3*y^2+2.*x.^2);
sigmax=(F./(pi.*R))-((4*F*R.*x.^2)./(pi.*K)).*C;
plot(x,sigmax)
  1 件のコメント
Ivan
Ivan 2018 年 1 月 10 日
Thank you for the help, I guess I'm just blind.

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

カテゴリ

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