Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
How to generate a Sine with parameter input and output pre determined?
조회 수: 1 (최근 30일)
이전 댓글 표시
How to generate a Sine with parameter input and output pre determined?
Hello, I need to generate 3 million files based cuvas with values X, Y (Time, Amplitude) of type Float for both.
How can I make a function that I indicate the time, amplitude, and get a txt file of data for each curve?
댓글 수: 0
답변 (2개)
Nir Rattner
2014년 8월 4일
편집: Nir Rattner
2014년 8월 5일
Given a sinusoid of the form “y = A * sin(w * x)”, I’m assuming you want the function to take “A” and “w” as parameters. The code below also assumes that “x” will span one period. The results will be saved as a text file based on the given name “outputFile”.
Edit: Based on your comment, it seems that you want to be able to control the amplitude, period, start time, and end time. In that case it seems like the following function should give you the correct results. "A" represents the amplitude, "T" represents the period, and "t" represents a vector that contains all of the time values.
function sineFunction(A, w, t, outputFile)
y = A * sin(t * 2 * pi / T);
save(outputFile, 't', 'y', '-ASCII');
Here is the function call you would make for the example you gave:
sinFunction(180, 10, 0 : 0.01 : 5, 'out.txt');
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!