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
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
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!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dialog Boxes 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!