Normalize and integrate a curve

40 Ansichten (letzte 30 Tage)
Pouyan Msgn
Pouyan Msgn am 10 Mär. 2020
Kommentiert: Image Analyst am 10 Mär. 2020
Hello!
If I want to normalize and integrate this curve, how should I do it?
clc
clear all
Data1=importdata('J30.txt');
x=Data1(:,1);
y=Data1(:,2);
plot(x,y)
  2 Kommentare
John D'Errico
John D'Errico am 10 Mär. 2020
trapz won't integrate it? Gosh, I thought it was supposed to do that.
What does normalize mean to you? Divide by the integral perhaps?
Pouyan Msgn
Pouyan Msgn am 10 Mär. 2020
yes, If I want to devide by the integral how should I do?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 10 Mär. 2020
Try this:
% Initialization steps.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
Data1=importdata('J30.txt');
x=Data1(:,1);
y=Data1(:,2);
% Plot original data.
subplot(3, 1, 1);
plot(x, y, 'LineWidth', 2);
grid on
title('Original data', 'FontSize', fontSize);
% Normalize by dividing by y Max
y2 = y / max(y);
% Plot normalized data.
subplot(3, 1, 2);
plot(x, y2, 'LineWidth', 2);
grid on
title('Normalized by Max Y signal', 'FontSize', fontSize);
% Find the area under the original y curve
area = trapz(y)
% Normalize by dividing by y Max
y3 = y / area;
area3 = trapz(y3)
% Plot normalized data.
subplot(3, 1, 3);
plot(x, y3, 'LineWidth', 2);
grid on
title('Normalized by Area under the curve', 'FontSize', fontSize);
  7 Kommentare
Pouyan Msgn
Pouyan Msgn am 10 Mär. 2020
Bearbeitet: Pouyan Msgn am 10 Mär. 2020
but how should the answer be right now? Must I normalize the x axis?
Image Analyst
Image Analyst am 10 Mär. 2020
We don't know exactly what you want. Only you know that. I made two guesses as to what you possibly might want. Does any of them look like what you might want?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu File Operations finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by