Effacer les filtres
Effacer les filtres

How to change the values of both axes

3 vues (au cours des 30 derniers jours)
Yu Xian Lim
Yu Xian Lim le 11 Oct 2021
Commenté : Chunru le 12 Oct 2021
I am trying to change the values of both axes from scientific notation to general form but I don't know how
Below is my code:
%Define variables
sigma = 35*10^6;
young_modulus = 90*10^9;
strain_coefficient = 6*10^-9;
magnetic_field = linspace(0, 160000);
%Function
stress = (sigma/young_modulus) + (strain_coefficient*magnetic_field);
%Create Plot
plot(magnetic_field, stress)
xlabel('Magnetic Field Intensity (A/m)')
ylabel('Microstrain (m/m)')
title('Microstrain vs. Magnetic Field Intensity')
This is the result I am looking for:

Réponse acceptée

Star Strider
Star Strider le 11 Oct 2021
There are ways to change the exponent display of the axis rulers using the NumericRuler Properties, however that is not necessary here. Just multiply the plot arguments by the appropriate scaling factors —
%Define variables
sigma = 35*10^6;
young_modulus = 90*10^9;
strain_coefficient = 6*10^-9;
magnetic_field = linspace(0, 160000);
%Function
stress = (sigma/young_modulus) + (strain_coefficient*magnetic_field);
%Create Plot
figure
plot(magnetic_field, stress)
xlabel('Magnetic Field Intensity (A/m)')
ylabel('Microstrain (m/m)')
title('Microstrain vs. Magnetic Field Intensity')
figure
plot(magnetic_field*1E-3, stress*1E+6)
xlabel('Magnetic Field Intensity (kA/m)')
ylabel('Microstrain (\mum/m)')
title('Microstrain vs. Magnetic Field Intensity')
Make appropriate changes to get different results.
.
  4 commentaires
Yu Xian Lim
Yu Xian Lim le 11 Oct 2021
got it! thanks!
Star Strider
Star Strider le 11 Oct 2021
As always, my pleasure!
.

Connectez-vous pour commenter.

Plus de réponses (1)

Chunru
Chunru le 11 Oct 2021
%Define variables
sigma = 35*10^6;
young_modulus = 90*10^9;
strain_coefficient = 6*10^-9;
magnetic_field = linspace(0, 160000);
%Function
stress = (sigma/young_modulus) + (strain_coefficient*magnetic_field);
%Create Plot
plot(magnetic_field/1000, stress*1e6)
xlabel('Magnetic Field Intensity (kA/m)')
ylabel('Microstrain (\mu m/m)')
title('Microstrain vs. Magnetic Field Intensity')
h=gca;
% Turn off the exponents
h.XAxis.Exponent=0;
h.YAxis.Exponent=0;
  2 commentaires
Yu Xian Lim
Yu Xian Lim le 11 Oct 2021
Is there a reason why we need these lines:
h=gca;
% Turn off the exponents
h.XAxis.Exponent=0;
h.YAxis.Exponent=0;
I tried it without these lines and it works the same?
Chunru
Chunru le 12 Oct 2021
This is to turn off the exponents if you have different values for two axes.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Stress and Strain 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!

Translated by