semilogx — Plot data with a logarithmic x-axis for response curves, scaling analysis, and MATLAB semilogx workflows.
semilogx creates the same line objects as plot, but configures the current axes to use a logarithmic x-axis. That makes it useful for response curves, magnitude plots, and data that spans orders of magnitude along X while still using familiar MATLAB semilogx call forms.
How semilogx works in RunMat
- The builtin returns the same kind of numeric line handle as
plot. - Only the x-axis is switched to log scale; the y-axis remains linear.
- Axes log-mode state is subplot-local, so
semilogxon one subplot does not force every axes in the figure into log mode. - Positive x-values are the meaningful domain for a logarithmic axis, even though the plotted line object still preserves the original data handle semantics.
Examples
Plot a frequency response with a logarithmic x-axis
f = logspace(0, 4, 200);
mag = 1 ./ sqrt(1 + (f / 200).^2);
semilogx(f, mag);Compare two responses on the same semilog x-axis
f = logspace(0, 4, 200);
h1 = semilogx(f, 1 ./ sqrt(1 + (f / 200).^2));
set(h1, 'DisplayName', 'low-pass');
hold on;
h2 = semilogx(f, (f / 200) ./ sqrt(1 + (f / 200).^2));
set(h2, 'DisplayName', 'high-pass');
legend;Verify the x-axis scale through handle/property workflows
f = logspace(1, 3, 50);
semilogx(f, log10(f));
ax = gca;
get(ax, 'XScale')Expected output:
ans =
'log'FAQ
When should I use semilogx instead of plot?
Use semilogx when your x-data spans several orders of magnitude and you care about relative differences across that range. Frequency response curves (Bode magnitude plots) are the classic example — frequencies from 1 Hz to 100 kHz are unreadable on a linear axis but spread evenly on a log scale.
How is semilogx different from calling plot and then switching the x-axis to log?
Functionally identical. semilogx(x, y) is shorthand for plot(x, y) followed by set(gca, 'XScale', 'log'). The convenience form just does both in one call and makes intent clearer when reading code.
What happens if my x-data contains zero or negative values?
Logarithmic axes only render positive values. Zero and negative x-values are silently excluded from the rendered line — the data handle still holds them, but they won't appear on the plot. Filter your data to the positive domain if you need a continuous curve.
Related functions to explore
These functions work well alongside semilogx. Each page has runnable examples you can try in the browser.
More plotting resources
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how semilogx works, line by line, in Rust.
- View semilogx.rs on GitHub
- Learn how the runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code — faster, on any GPU, with no license required.
- Simulations that took hours now take minutes. RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed.
- Start running code in seconds. Open the browser sandbox or download a single binary. No license server, no IT ticket, no setup.
- A full development environment. GPU-accelerated 2D and 3D plotting, automatic versioning on every save, and a browser IDE you can share with a link.