I am trying to show an average line of these lines shown in the figure. Here i am plotting a stress vs strain curve with 7 different test samples. To perform my analysis i want to take the average of these lines but i am not sure what function to use.

2 commentaires

Caylin Levin
Caylin Levin le 3 Août 2017
this is the code i am using where the Blake_ is my data input. I dont think i can use the mean function cause each test is a different number of data points
Stress01 =(blake_uv_h_natural_test1_force*4.4482216)./(6*5);
Stress02 =(blake_uv_h_natural_test2_force*4.4482216)./(6*5);
Stress03 =(blake_uv_h_natural_test3_force*4.4482216)./(6*5);
Stress04 =(blake_uv_h_natural_test4_force*4.4482216)./(6*5);
Stress05 =(blake_uv_h_natural_test5_force*4.4482216)./(6*5);
Stress06 =(blake_uv_h_natural_test6_force*4.4482216)./(6*5);
Stress07 =(blake_uv_h_natural_test7_force*4.4482216)./(6*5);
Strain01 = (((blake_uv_h_natural_test1_disp*25.4)+115)-115)./115;
Strain02 = (((blake_uv_h_natural_test2_disp*25.4)+115)-115)./115;
Strain03 = (((blake_uv_h_natural_test3_disp*25.4)+115)-115)./115;
Strain04 = (((blake_uv_h_natural_test4_disp*25.4)+115)-115)./115;
Strain05 = (((blake_uv_h_natural_test5_disp*25.4)+115)-115)./115;
Strain06 = (((blake_uv_h_natural_test6_disp*25.4)+115)-115)./115;
Strain07 = (((blake_uv_h_natural_test7_disp*25.4)+115)-115)./115;
figure;
plot(Strain01, Stress01 ,'b-','MarkerSize',14,'LineWidth',2);
hold on;
plot(Strain02, Stress02 ,'-','MarkerSize',14,'LineWidth',2);
plot(Strain03, Stress03 ,'-','MarkerSize',14,'LineWidth',2);
plot(Strain04, Stress04 ,'-','MarkerSize',14,'LineWidth',2);
plot(Strain05, Stress05 ,'-','MarkerSize',14,'LineWidth',2);
plot(Strain06, Stress06 ,'-','MarkerSize',14,'LineWidth',2);
plot(Strain07, Stress07 ,'-','MarkerSize',14,'LineWidth',2);
hold off;
legend('01','02','03','04','05','06','07','Location','NorthEast','Orientation','Horizontal');
grid on; grid minor; set(gca,'FontSize',16);
xlabel('Strain [%]');
ylabel('Stress [MPa]');
xlim('auto');
ylim('auto');
set(gca,'GridLineStyle','-','MinorGridLineStyle','-');
Jan
Jan le 4 Août 2017
Modifié(e) : Jan le 4 Août 2017
Do not hide indices in the names of variables. See http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval. If you store the data in an array instead, the handling of an arbitrary number of signals is trivial and much nicer.
Example:
% Instead of
blake_uv_h_natural_test1_force, blake_uv_h_natural_test2_force, ...
% One vector:
blake_uv_h_natural_test_force(1:7)
Then:
Stress = blake_uv_h_natural_test_force * (4.4482216 / 30);
In consequence the pice of code you have posted will be 17 lines shorter and even faster. Most of all it will be easier to debug, less prone to typos and to expand the code to more channels you would not have to change a single line of code.
By the way: I prefer shorter names, e.g. by using the CamelCase:
blakeUVhNaturalTestF
but this is a question of taste.

Connectez-vous pour commenter.

Réponses (1)

the cyclist
the cyclist le 3 Août 2017

1 vote

Can you use the mean function?

4 commentaires

Caylin Levin
Caylin Levin le 3 Août 2017
please see my code
the cyclist
the cyclist le 3 Août 2017
You could use interp1 to interpolate to a common set of Strain points, then take the mean.
Caylin Levin
Caylin Levin le 3 Août 2017
I have attempted to do this but seems that i am not that familiar with this function. How would i implement this function in my code?
the cyclist
the cyclist le 3 Août 2017
It's pretty straightforward. It will be something like
StrainCommonPoints = 0.001:0.001:0.030;
Stress01_extrap = interp1(Strain01,Stress01,StrainCommonPoints)
and do the same for the other stress variables.
By the way, I'd just like to point out that there are also many other ways your code could be improved.
Rather than copying the same numbers (e.g. 4.4482216) over and over again, standard practice would be to define a parameter, like
StressConstant = 4.4482216;
and use that. It makes your code less error-prone, and will help you (or others) remember later what that is.
There are other things as well (like using cell arrays instead of variables named x1, x2, x3).

Connectez-vous pour commenter.

Catégories

En savoir plus sur Stress and Strain dans Centre d'aide et File Exchange

Modifié(e) :

Jan
le 4 Août 2017

Community Treasure Hunt

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

Start Hunting!

Translated by