필터 지우기
필터 지우기

Loop for repeating a process multiple times

조회 수: 3 (최근 30일)
Shahab Khan
Shahab Khan 2019년 11월 19일
댓글: Shahab Khan 2019년 11월 20일
Hello
I am trying to write a loop which can perfrom same calculation for different values.
I have variables:
E = 100;
I = [1 2 3 4 . . . . 100] % size 101*1
C = 1;
Loss = 13;
Loss_E = (E*Loss)/100;
T_s = E / I*C;
T_l = Loss_E / I * C
T = T_s + T_l
Can somehelp me with writing a loop which perform calculation for
T
for all values of
I
.Thanks

채택된 답변

Erivelton Gualter
Erivelton Gualter 2019년 11월 19일
You need to use the ./ operator to perform division of arrays.
Try this
E = 100;
I = 1:100;
C = 1;
Loss = 13;
Loss_E = (E*Loss)/100;
T_s = E./I*C;
T_l = Loss_E./I*C;
T = T_s + T_l

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by