graphical solution to plot the transcendental eauation-Array indices must be positive integers or logical values.

조회 수: 1 (최근 30일)
for the transcendental eauation to be like this-->
I want to plot the figure above .
PHI is a matrix , it will chamge its value as our other values change.
like the following
PHI(:,1)=V(:,xsteps-0);
PHI(:,2)=V(:,xsteps-1);
PHI(:,3)=V(:,xsteps-2);
----------------------------------------------------------------
the code downside is the problem
the system tell me that
"Array indices must be positive integers or logical values."
Error in this line --> sin(PHI)=linspace(0,lambda/(4*n1*W/2),sqrt(2*delta))
can anyone help me plot this figure or tell me how to fix my code?
----------------------------------------------------------------
【this is my main code】
for m=0:8
sin(PHI)=linspace(0,lambda/(4*n1*W/2),sqrt(2*delta));
plot(sin(PHI),(atan(sqrt(2*delta./(sin(PHI).^2)-1))+m*pi/2)/(ko*n1*(W/2)))
ylim([0 10])
end
-----------------------------------
  댓글 수: 1
Jeffrey Clark
Jeffrey Clark 2022년 10월 16일
@御方 羅, you can't have a function reference on the left side of the equals and you should not use function names as variable names if sin(PHI) is your variable array name and index. Since you are getting the error "Array indices must be positive integers or logical values" I suspect you want:
PHI = linspace(0,lambda/(4*n1*W/2),sqrt(2*delta));

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

답변 (1개)

Mann Baidi
Mann Baidi 2023년 9월 7일
Hi,
I understand you would like to plot “sin(PHI)” vs “atan()” graph and you are facing issue in assigning values to “PHI”. This is because you cannot assign values to a function in MATLAB. If you want to assign value to “PHI” the correct syntax would be
PHI = linspace(0,lambda/(4*n1*W/2),sqrt(2*delta));
Or if you would like to use the equation as
PHI=sin-1(linspace(0,lambda/(4*n1*W/2),sqrt(2*delta)
You can use the “asin” function.
PHI=asin(linspace(0,lambda/(4*n1*W/2),sqrt(2*delta)));
For more information on the "asin" function, you can refer to the following documentation:
Hope this helps!

카테고리

Help CenterFile Exchange에서 Dialog Boxes에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by