fullfile — Build a platform-correct file path from multiple path segments.
fullfile joins path segments using the platform-specific file separator, producing a single path string that matches MATLAB semantics. It accepts any number of path segments and returns a character row vector (1xN).
How fullfile works
fullfile(part1, part2, ...)joins the inputs with the platform file separator (/on macOS and Linux,\on Windows).- Absolute path segments reset the accumulated path, mirroring MATLAB and OS path rules.
- Empty segments are ignored, so
fullfile("", "data")returnsdata. - Inputs must be character vectors or string scalars. Single-element string arrays are accepted. Other input types raise
fullfile: arguments must be character vectors or string scalars. - The output is a character vector. Wrap the result with
string(...)if you prefer string scalars.
How RunMat runs fullfile on the GPU
fullfile performs string manipulation on the CPU only. Any GPU-resident inputs are gathered to the host before path assembly so the resulting character vector is always in CPU memory.
GPU memory and residency
No. fullfile is a host-side path builder. GPU-resident text inputs are gathered automatically, so there is no benefit to keeping path strings on the GPU.
Examples
Join Relative Path Segments
p = fullfile("data", "raw", "sample.dat")Expected output:
p =
data/raw/sample.datUse fullfile With pwd
root = pwd;
config = fullfile(root, "config", "settings.json")Expected output:
% Returns a full path rooted at the current working folderBuild A Subfolder Path
logDir = fullfile("logs", "2026");
status = mkdir(logDir)Expected output:
status =
1Create A File In A Nested Folder
mkdir(fullfile("data", "raw"));
fid = fopen(fullfile("data", "raw", "sample.dat"), "w");
fclose(fid)Expected output:
% Creates data/raw/sample.datFAQ
Why does fullfile return a character vector instead of a string?⌄
MATLAB returns character vectors for fullfile. RunMat mirrors that behavior for compatibility; use string(fullfile(...)) if you prefer string scalars.
Does fullfile expand ~ to the home directory?⌄
No. fullfile performs string assembly only. Use cd or filesystem APIs that expand ~ when you need home expansion.
What happens if a segment is absolute?⌄
Absolute segments reset the accumulated path, matching MATLAB and OS path rules.
Can I pass numeric character codes?⌄
Yes. Numeric arrays that represent character codes are accepted as long as they form a row vector, just like other RunMat text inputs.
Does fullfile run on the GPU?⌄
No. It is a host-only utility and gathers GPU-resident inputs before processing.
Related Io functions
Repl Fs
addpath · cd · copyfile · delete · dir · exist · genpath · getenv · ls · mkdir · movefile · path · pwd · rmdir · rmpath · savepath · setenv · tempdir · tempname
Tabular
csvread · csvwrite · dlmread · dlmwrite · readmatrix · writematrix
Filetext
fclose · feof · fgetl · fgets · fileread · filewrite · fopen · fprintf · fread · frewind · fwrite
Json
Http
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how fullfile works, line by line, in Rust.
- View fullfile.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.