MATLAB Answers

How can I multiply axis values by 1000 without changing the data?

110 views (last 30 days)
onamaewa on 11 Apr 2019
Commented: Rik on 16 Apr 2019
With the script shown below,
for CH = 2:33
Y = (avg(:,CH) - avgBG(CH) + SP);
hold on
plot(avg(:,1), Y)
xlim([0 0.3]); xlabel('Time (s)');
ylim([-0.034 0.034]); ylabel('Position (m)');
SP = SP + 2/1000;
I've created this figure:
I want to change the Y-axis values on the figure to be multiplied by 1000.
I tried Yticks, but I don't think I've implemented it correctly. Any suggestions?


Sign in to comment.

Answers (1)

Rik on 11 Apr 2019
You can either multiply the y-values with 1000, or use the YTickLabels:
ticks=get(gca,'YTicks');%retrieve current ticks
ticks=cellfun(@num2str,tick,'UniformOutput',false);%convert to cellstr
set(gca,'YTickLabels',ticks)%set new tick labels

  1 Comment

Rik on 16 Apr 2019
Did this suggestion solve your problem? If so, please consider marking it as accepted answer. It will make it easier for other people with the same question to find an answer. If this didn't solve your question, please comment with what problems you are still having.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by