Hello,
I have an error in my sigma_3b line and I can't plot my graph because of it. I was wondering if someone could help me figure out why my calculation won't complete. Here's my code down bellow.
clc, clear all,close all
u=0.166;
k1=5.140;
k2=337.6;
lambda_3b=1.0:0.05:2.0;
sigma_3b=(u*(lambda_3b.^1)).*((lambda_3b.^1)-1)+(2*k1)*((lambda_3b.^2)-1).*(exp(k2*((lambda_3b.^2)-1))^2);
figure
plot(lambda_3b,sigma_3b)
title('Sigma 1, Sigma 2 vs Lambda')
xlabel('Stretch Ratio Lambda')
ylabel('Principle Stretch (P/Ao)')
legend('\sigma 3b')

 Respuesta aceptada

Star Strider
Star Strider el 28 de Mzo. de 2018
You forgot to vectorise the last square:
sigma_3b=(u*(lambda_3b.^1)).*((lambda_3b.^1)-1)+(2*k1)*((lambda_3b.^2)-1).*(exp(k2*((lambda_3b.^2)-1)).^2);
↑ ← VECTORISE HERE
Also, raising something to the 1-th power is simply inefficient:
(lambda_3b.^1)).*((lambda_3b.^1)
What do you actually want to do in that sub-expression?

4 comentarios

Vongola_X
Vongola_X el 28 de Mzo. de 2018
I'm attempting to plot a graph from this equation in the image.
Star Strider
Star Strider el 28 de Mzo. de 2018
This is a bit more efficient, and the plot is more informative:
u=0.166;
k1=5.140;
k2=337.6;
lambda_3b=1.0:0.05:2.0;
sigma_3b = u*lambda_3b.*(lambda_3b-1) + (2*k1)*((lambda_3b.^2)-1) .* exp(k2*((lambda_3b.^2)-1).^2);
figure
plot(lambda_3b,sigma_3b)
title('Sigma 1, Sigma 2 vs Lambda')
xlabel('Stretch Ratio Lambda')
ylabel('Principle Stretch (P/Ao)')
legend('\sigma 3b')
set(gca, 'YScale','log')
Vongola_X
Vongola_X el 28 de Mzo. de 2018
This helped clarify my mistakes. Thank you!
Star Strider
Star Strider el 28 de Mzo. de 2018
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 28 de Mzo. de 2018

Comentada:

el 28 de Mzo. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by