Please help me understand the use of dot operator

585 ビュー (過去 30 日間)
Tsansoterra
Tsansoterra 2020 年 2 月 18 日
コメント済み: Star Strider 2020 年 2 月 18 日
Hello. I have been having this same problem in a lot of the homework assignments I have been given so far.
What I am trying to do is use the while loop to create values for J, and in the same loop I am trying to use those values of
J to create a new array with the values from tau.
clc; clear ; clear all
F = 10; %Newtons
T = F*0.1 ; %Work
r = 0:5; %mm
i = 1
while i < 6
J = (.5*pi)*r.^4
tau(i) = (T*r)/J
i = i + 1;
end
  2 件のコメント
KSSV
KSSV 2020 年 2 月 18 日
Okay..what is the question now?
Tsansoterra
Tsansoterra 2020 年 2 月 18 日
How do I get the values of tau using the values of J and r ? The method for J where I used a dot operator does not work for tau to cycle through the values of the array.

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

採用された回答

Star Strider
Star Strider 2020 年 2 月 18 日
The dot operator, used with multiplication, division, and exponentiation, creates element-wise oiperations. See Array vs. Matrix Operations for a full explanation.
The one exception to that is the use of the dot operator in creating matrix transposes. The ‘regular’ matrix transpose (') creates the complex-conjugate transpose of a complex vector or matrix. Using the (.') creates the transpose without doing the complex-conjugate operation.
  3 件のコメント
Tsansoterra
Tsansoterra 2020 年 2 月 18 日
Thank you. That was very insightful, and It gave me the asnwer I was looking for.
Star Strider
Star Strider 2020 年 2 月 18 日
As always, my pleasure!
I do my best to provide complete explanations!

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

その他の回答 (1 件)

David Hill
David Hill 2020 年 2 月 18 日
Not sure what you want tau to be. Currently you have an array (T*r) divided by another array (J). If you want to generate a tau matrix, then:
tau(i,:)=(T*r)./J;
If tau is suppose to be a 6 element array, then I suppect what you meant was:
F = 10; %Newtons
T = F*0.1 ; %Work
r = 0:5; %mm
J = (.5*pi)*r.^4;
tau = (T*r)./J;%need ./for element-wise operations
  1 件のコメント
Tsansoterra
Tsansoterra 2020 年 2 月 18 日
編集済み: Tsansoterra 2020 年 2 月 18 日
Hi David. Thank you for your response. I apologize for my laymen terms as this language is very new to me.
I have 3 equations ; T=F(0.1) , J=(pi/2)*r^4 , and tau = (T*r)/J
given ; r = 0:5 , T = 100, tau(max) = 100
I ultimately need to graph tau by r.
Using a while loop I am trying to get an array of answers for tau, so that I can graph it. Tau depends on the value J.
So what I want to do is run a while loop 5 times to represent each value of r. In this loop I am trying to solve for J, and then solve for tau using the found values of J.
Thanks again for your time.

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

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by