Jump to content
  • Announcements

    • Rahul Ponginan

      Please click here for a short but important announcement   03/26/17

      Dear Users Our Commercial and Academic users around the world can use these same forums here as before i.e. the Altair Support Forum , Commercial users from India with solver queries can go to the Solver Forum for India Commercial Users , Academic Users from India and AOC India Participants are requested to go to the Forum for India Academic Users and AOC India Participants , We will be tending to all queries in all the forums promptly as before, thank you for your understanding. 
    • Rahul Ponginan

      ユーザーフォーラムについて   10/22/17

      アルテアエンジニアリングでは、弊社製品や技術について、ユーザー様同士がオンラインで情報交換できる場所を提供しています。 日常業務の中で起こるさまざまな問題の解決や、他ユーザー様との技術交流を図るための場として、お客様の環境に合わせてご活用ください。
Sign in to follow this  
Novak

Plot

Recommended Posts

Hello

 

I am a beginner at solidthinking COMPOSE. I just want to know how to plot the following function. I have written the code, but it shows the error.
Also, would be great if someone can show me the command for 3D plot

 

sigma_inf=100;
a=10;
r=10;
theta=[0:0:pi/2];
sigma_rr = @(theta)((sigma_inf/2)*(1-(a/r)^2))+(sigma_inf/2)*(1-4*(a/r)^2+3*(a/r)^4)*cos(2*theta);
sigma_theta =@(theta)((sigma_inf/2)*(1+(a/r)^2))-(sigma_inf/2)*(1+3*(a/r)^4)*cos(2*theta);

plot(theta,sigma_rr);

 

Thanks in advance

Share this post


Link to post
Share on other sites

Hi Novak,

           I have made some changes in the code and it works fine for me. The 3-D plot is attached with this reply. The updated code is given below. The errors you made is also mentioned here.

 

1) Syntax  theta=[0:0:pi/2]; is wrong

2) There is no need to mention @(theta) in Line no.5 and Line.no.6.

3) Use plot3 for obtaining 3-D plot.

 

Thanks

Sijo George

 

%%-----Updated Code

sigma_inf=100;
a=10;
r=10;
theta=[0:0.1:pi/2];
sigma_rr = (((sigma_inf/2)*(1-(a/r)^2))+(sigma_inf/2)*(1-4*(a/r)^2+3*(a/r)^4))*cos(2*theta);
sigma_theta =(((sigma_inf/2)*(1+(a/r)^2))-(sigma_inf/2)*(1+3*(a/r)^4))*cos(2*theta);
plot3(theta,sigma_rr,sigma_theta);

Figure 1.png

Share this post


Link to post
Share on other sites

Thanks a lot george

 

Just one more question

 

What if I want to make sigma_rr as a function of 'theta' and 'r' and I want 'r' to go from 10 to 100

shouldn't this work?

 

sigma_inf=100;
 a=10;
 
 theta=[0:0.1:pi/2];
 r=[0:10:100];
 
 sigma_rr = (((sigma_inf/2)*(1-(a/r)^2))+(sigma_inf/2)*(1-4*(a/r)^2+3*(a/r)^4))*cos(2*theta);
 sigma_theta =(((sigma_inf/2)*(1+(a/r)^2))-(sigma_inf/2)*(1+3*(a/r)^4))*cos(2*theta);
 plot3(theta,r,sigma_rr,sigma_theta);

Share this post


Link to post
Share on other sites

just to clarify i want to plot just 'sigma_rr' as a function of 'theta' and 'r'. So i tried removing the 'sigma_theta' from the last line but it still shows error

Share this post


Link to post
Share on other sites

Hi Novak,

           The following code works for me. I made the following changes.

1) Used for loop

2) Removed sigma_theta from the last line. This is because plot3 command accepts only three inputs.

3) Used linspace command to include the radius range.

 

Thanks

Sijo George

 

 

%%%%----Updated code

sigma_inf=100;
a=10;
theta=[0:0.1:pi/2];
r = linspace(0,100,16);

 for i = 1:length(r)
 sigma_rr = (((sigma_inf/2)*(1-(a/r(i))^2))+(sigma_inf/2)*(1-4*(a/(i))^2+3*(a/r(i))^4))*cos(2*theta);
 end
 for i = 1:length(r)
 sigma_theta =(((sigma_inf/2)*(1+(a/r(i))^2))-(sigma_inf/2)*(1+3*(a/r(i))^4))*cos(2*theta);
 end
 plot3(theta,r,sigma_rr);

Figure 1.png

Share this post


Link to post
Share on other sites

Thanks George

But why did you write 16 in the following line and why do we need to specify 0 at the beginning

r = linspace(0,100,16);

If i want to go from 10 to 100, then  shouldn' it just be:  r = linspace(10,100);

 

Share this post


Link to post
Share on other sites

It is because theta has only 16 elements. All variables must have equal number of elements. If you change the number of elements in theta, you must make the corresponding changes in 'r' also. Otherwise plotting and other operations will not take place.

 

Thanks

Sijo George

Rahul R likes this

Share this post


Link to post
Share on other sites

Hi

I have couple more questions. For the following, again there is an error. I am assuming it is again something to do with number of elements in theta but not sure how to resolve it. I do want to plot2D between 'sigma_theta' and 'r' and 'r' must go from 10 to 100.

Secondly, how to do I label the axes in this case. If i want to call X-axis 'r' and Y-axis 'sigma_theta'

 

sigma_inf=100;
a=10;
theta=pi/2;
r=[0:10:100];
sigma_rr = (((sigma_inf/2)*(1-(a/r)^2))+(sigma_inf/2)*(1-4*(a/r)^2+3*(a/r)^4))*cos(2*theta);
sigma_theta =(((sigma_inf/2)*(1+(a/r)^2))-(sigma_inf/2)*(1+3*(a/r)^4))*cos(2*theta);
plot(r,sigma_theta);

 

Thanks

Share this post


Link to post
Share on other sites

Hi,

      Use the following code for the problem you have mentioned above.

 

Thanks

Sijo George

 

%%------Code-----------------

sigma_inf=100;
a=10;
theta=pi/2;
r=[0:10:100];
for i = 1:length(r)
sigma_rr(i) = (((sigma_inf/2)*(1-(a/r(i))^2))+(sigma_inf/2)*(1-4*(a/r(i))^2+3*(a/r(i))^4))*cos(2*theta);
end
for i = 1:length(r)
sigma_theta(i) =(((sigma_inf/2)*(1+(a/r(i))^2))-(sigma_inf/2)*(1+3*(a/r(i))^4))*cos(2*theta);
end
plot(r,sigma_theta);
xlabel('Radius(m)');
ylabel('Sigma_Theta')

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×