Surface Generation MATLAB Code
Surface Generation MATLAB Code
close all;
clear;
clc;
% Define parameters
length = 10; % Length in mm
Ra_target = 0.6; % Target Ra value in microns
Rq_target = 0.76; % Target Rq (RMS) value in microns
Rsk_target = 0.05; % Target Rsk (skewness) value in microns
Rku_target = 3.45; % Target Rku (kurtosis) value in microns
y = y * (Ra_target / Ra_current);
y = y * (Rq_target / Rq_current);
y = y + (Rsk_target - Rsk_current);
y = y + (Rku_target - Rku_current);
3D Surface Generation
close all;
clear;
clc;
% Set the random seed for reproducibility
rng(1234);
% Parameters
width = 100; % Width of the surface
height = 100; % Height of the surface
scale = 0.1; % Scale of the surface
octaves = 3; % Number of octaves
persistence = 0.5; % Persistence of the noise
defectX = 50; % X-coordinate of the defect
defectY = 50; % Y-coordinate of the defect
defectRadius = 1; % Radius of the defective area
defectAmplitude = 1; % Amplitude of the defect
smoothingRadius = 2; % Radius of the smoothing filter
% Create meshgrid
[X, Y] = meshgrid(1:width, 1:height);