필터 지우기
필터 지우기

Please help me understand the use of dot operator

조회 수: 614 (최근 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 CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by