Initial commit
This commit is contained in:
parent
ce71836e83
commit
d5325f4a59
47
MMS24_25.c
Normal file
47
MMS24_25.c
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
//
|
||||||
|
// Created by minhd on 03.12.2024.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "MMS24_25.h"
|
||||||
|
#include "math.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#ifdef _DEBUG_
|
||||||
|
printf("X=%f\n",x);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
double interpolateLine(double x1, double y1,double x2, double y2, double x){
|
||||||
|
double y = ((y2 - y1) / (x2 - x1)) * x + y1 - ((y2 - y1) / (x2 - x1)) * x1;
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rescaleDoubleArray(double *pdIn, int iLen, int iMin, double dFactor, double *pdOut){
|
||||||
|
for (int i = 0; i < iLen; i++) {
|
||||||
|
pdOut[i] = pdIn[i + iMin] * dFactor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double *generateSineValues(int iNumValues, int iNumSamplesPerPeriod, double dAmp){
|
||||||
|
double* sineArray = (double*)malloc(iNumValues * sizeof(double));
|
||||||
|
for (int i=0; i<iNumValues;i++){
|
||||||
|
sineArray[i] = dAmp*sin(((2*M_PI)/iNumSamplesPerPeriod) * i);
|
||||||
|
}
|
||||||
|
return sineArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeDoubleArray(double *pdOut, int iLen, char *pcOutName) {
|
||||||
|
FILE* datei = fopen(pcOutName, "w");
|
||||||
|
if (datei == NULL) {
|
||||||
|
printf("Fehler beim Öffnen der Datei.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < iLen; i++) {
|
||||||
|
fprintf(datei, "%f\n", pdOut[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(datei);
|
||||||
|
|
||||||
|
}
|
||||||
14
MMS24_25.h
Normal file
14
MMS24_25.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
//
|
||||||
|
// Created by minhd on 03.12.2024.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef MMS_LOESUNG_2024_25_MMS24_25_H
|
||||||
|
#define MMS_LOESUNG_2024_25_MMS24_25_H
|
||||||
|
|
||||||
|
double interpolateLine(double dX1,double dY1,double dX2, double dY2, double dXq);
|
||||||
|
void rescaleDoubleArray(double *pdIn, int iLen, int iMin, double dFactor, double *pdOut);
|
||||||
|
double *generateSineValues(int iNumValues, int iNumSamplesPerPeriod, double dAmp);
|
||||||
|
void writeDoubleArray(double *pdOut, int iLen, char *pcOutName);
|
||||||
|
int readDoubleArray(char *pcInName, double **ppdIn);
|
||||||
|
|
||||||
|
#endif //MMS_LOESUNG_2024_25_MMS24_25_H
|
||||||
Loading…
Reference in New Issue
Block a user