# How can I set max & min value but maintain the curve trend?

9 visualizzazioni (ultimi 30 giorni)
Vivian Yu il 19 Feb 2022
Risposto: Catalytic il 19 Feb 2022
Hello everyone,
I have a fitting curve as you can see in figure below.
I want to make maximum value is equal to 1 and minimum value is equal to 0.
However, I also want to maintain the curve trend.
How can I do?
clear all
clc
clf
close all
filename = ('PDA36A_spectrum2_sam.xlsx');
points = data(:,1);
signal = data(:,2);
% Get smoothed signal.
figure
title('Weighting shape');
xlabel('wavelength (nm)');
ylabel('Ratio');
set(gca,'fontsize',15,'linewidth',1);
grid on
When I use function "interp1", the result is so bad.
smoothedSignal = smoothedSignal'./max(smoothedSignal);
range = linspace(0,1,length(smoothedSignal))';
spectruma=interp1(smoothedSignal,maskedWave,range,'spline'); %interpolate the exp data interp1(x,y,xi,method)
figure
plot(spectruma);
Thank you!
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Walter Roberson il 19 Feb 2022
rescale()?

Accedi per commentare.

### Risposta accettata

Catalytic il 19 Feb 2022
yourSignal = rescale(yourSignal)
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Più risposte (1)

Voss il 19 Feb 2022
clear all
clc
clf
close all
filename = ('PDA36A_spectrum2_sam.xlsx');
points = data(:,1);
signal = data(:,2);
Warning: Polynomial is badly conditioned. Add points with distinct X values, reduce the degree of the polynomial, or try centering and scaling as described in HELP POLYFIT.
% Get smoothed signal.
figure
title('Weighting shape');
xlabel('wavelength (nm)');
ylabel('Ratio');
set(gca,'fontsize',15,'linewidth',1);
grid on
% smoothedSignal = smoothedSignal'./max(smoothedSignal);
smoothedSignal = (smoothedSignal'-min(smoothedSignal))./(max(smoothedSignal)-min(smoothedSignal));
% smoothedSignal = rescale(smoothedSignal); % an alternative
% range = linspace(0,1,length(smoothedSignal))';
% spectruma=interp1(smoothedSignal,maskedWave,range,'spline'); %interpolate the exp data interp1(x,y,xi,method)
figure
% plot(spectruma);
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Exploration and Visualization 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