How to change the values of both axes

조회 수: 1 (최근 30일)
Yu Xian Lim
Yu Xian Lim 2021년 10월 11일
댓글: Chunru 2021년 10월 12일
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:

채택된 답변

Star Strider
Star Strider 2021년 10월 11일
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
Yu Xian Lim
Yu Xian Lim 2021년 10월 11일
got it! thanks!
Star Strider
Star Strider 2021년 10월 11일
As always, my pleasure!
.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Chunru
Chunru 2021년 10월 11일
%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
Yu Xian Lim
Yu Xian Lim 2021년 10월 11일
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 2021년 10월 12일
This is to turn off the exponents if you have different values for two axes.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Stress and Strain에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by