how to get data from an interval
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
federico midei
le 26 Sep 2020
Commenté : Ameer Hamza
le 27 Sep 2020
Hi, I need to use the y values between the x=50 and x=180 values to do another plot. How can I get these vaules from the current plot? I've readed some answers using the 'findobj' function but I don't know if it's the correct function for my task and I don't understand how to use it in my specific situation.
Could someone help me please?
here's my code:
clc;
clear;
close all;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
P=0.5*800000;%kN -carico agente
R=20;%mm -raggio medio
L=3*75;%mm -lunghezza tubo
s=1;%mm -spessore di parete
ni=0.3;% -coeff poisson
E=210000;%MPa -modulo young
w=2;%MPa -pressione int/ext
K=0.5;% -incasto incastro
%equazioni derivanti dall'equilibrio radiale:
E1=E/(1-(ni^2));% -modulo young dilataz laterale impedita
I=(2*pi*R*(s^3))/12;% -momento di inerzia cilindro
k=2*pi*((E*s)/R);% -rigidezza molla fondazione
Pcr=sqrt(4*k*E1*I)% -carico critico
Pcre=((pi)^2*E*I)/(K*((L/1000)^2))% -carico critico secondo Eulero
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f = @(z,u) [u(2); u(3); u(4); (-1/(E1*I))*((P*u(3))+(k*u(1)))]; %equazione differenziale w=0
bc = @(ua, ub) [ua(1); ua(2)-0.00000001; ub(1); ub(2)+0.00000001];
zmesh = linspace(0, L, 100000);%crea vettore equispaziato da 0->lunghezza cilindro
iguess= @(z) [0; 0; 0; 0];%initial guess @soluzione dalla quale inizia l'iterazione della function bvp4c
solinit = bvpinit(zmesh, iguess); %reference @doc bvpinit (form initial guess value)
opts = bvpset('RelTol',0.1,'AbsTol',0.1,'Stats','on'); %setting per ottenere le statistiche della function bvp4c
sol= bvp4c(f, bc, solinit,opts)% sol in x, y values
figure
hold on
grid on
plot(sol.x(1,:),sol.y(1,:),'.') %I need the y values from this plot for x from 50 to 180
legend('w=0');
xlabel('z');
ylabel('solution u');
0 commentaires
Réponse acceptée
Ameer Hamza
le 26 Sep 2020
Modifié(e) : Ameer Hamza
le 26 Sep 2020
You can use logical indexing. Add these lines at the end of your code
x = sol.x;
y = sol.y;
idx = (x > 50) & (x < 180);
figure
hold on
grid on
plot(x(idx), y(1, idx))
6 commentaires
Ameer Hamza
le 27 Sep 2020
Please check the code in the updated comment. You were using Sol as a variable name. I mistakenly typed sol.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Boundary Value Problems dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!