Filter löschen
Filter löschen

How to change the values of both axes

3 Ansichten (letzte 30 Tage)
Yu Xian Lim
Yu Xian Lim am 11 Okt. 2021
Kommentiert: Chunru am 12 Okt. 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:

Akzeptierte Antwort

Star Strider
Star Strider am 11 Okt. 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 Kommentare
Yu Xian Lim
Yu Xian Lim am 11 Okt. 2021
got it! thanks!
Star Strider
Star Strider am 11 Okt. 2021
As always, my pleasure!
.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Chunru
Chunru am 11 Okt. 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 Kommentare
Yu Xian Lim
Yu Xian Lim am 11 Okt. 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 am 12 Okt. 2021
This is to turn off the exponents if you have different values for two axes.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Stress and Strain finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by