# Add units to the chart

13 visualizzazioni (ultimi 30 giorni)
Chenglin Li il 13 Set 2023
I want to add (x10^9) to the end of the horizontal coordinate, something like this, how should I program it？
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Nathan Hardenberg il 13 Set 2023
Modificato: Nathan Hardenberg il 19 Set 2023
The number is added by default if you just use the high numbers directly
x = [10:0.1:12]*10^9;
y = sin(x);
plot(x,y)
-- EDIT --
If your x values range from 10 to 11.5 then you can simply multiply them for every plot you make:
x = [10:0.1:12]; % old x values from 10 to 12
y = sin(4*x);
x_new = x*10^9; % multiply with 10^9 to scale data accordingly. From 10e9 to 12e9
figure(1);
plot(x_new, y)
xlabel('Frequency (Hz)')
If you really want to use custom ticks, check out this link to the documentation. You could use the last tick to display, that the values are meant to be times 10^9
figure(2);
plot(x, y)
xlabel('Frequency (Hz)')
xticks([10 10.5 11 11.5 12])
xticklabels({'10', '10.5', '11', '11.5', 'x10^9'})
-- EDIT 2 --
Or in your case you could just edit the x-label to say "Frequency (GHz)". Since Gigaherz is x10^9 Hz
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Più risposte (1)

Chenglin Li il 13 Set 2023
set(gca,'XTick',[10.5*10^9:0.2*10^9:11.5*10^9])
xlabel('Frequency (Hz)');
My code looks like this, but after running it my horizontal coordinates don't show up
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Formatting and Annotation in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by