Looping Through Matrix indexing

조회 수: 2 (최근 30일)
C
C 2014년 10월 22일
댓글: José-Luis 2014년 10월 22일
I'm trying to solve an equation with multiple values for two variables. I can't seem to get the inner matrix to work which is variable Pc...
clear all, clc;
Mc = [120.2 119.9 119.9 119.9 119.7 119.8 119.6 119.3 119.1]; Pc = [121.4 121.4 121.3 121.2 121.5 121.7 121.6 121.8 121.5];
Vc = Mc(:)*cosd(Pc(:)) + Mc(:)*sind(Pc(:))*i

채택된 답변

Ced
Ced 2014년 10월 22일
Hi Since you want to compute Vc for each element, you need to use element-wise operations, meaning you have to add a dot "." in front of the operator as such:
Vc = Mc.*cosd(Pc) + Mc.*sind(Pc)*i
Cheers

추가 답변 (1개)

C
C 2014년 10월 22일
Wow... it's like magic lol, Thank you!
  댓글 수: 1
José-Luis
José-Luis 2014년 10월 22일
Please accept an answer if it solved your problem.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by