- #1
Trying2Learn
- 377
- 57
- TL;DR Summary
- IO in javascript: what is the question
Hello
A few weeks ago (March 7) I asked how to have Javascript read a data file of numbers into an array.
I now understand why this is such a challenge when running a code on a web page, locally.
I have since found a sufficient workaround. I hope I can share it in the hope that someone can tell me how I SHOULD have asked the question. (Yes, this is an odd question: I am actually asking FOR a question.)
Here is what I did.
After Matlab processed all the numbers, I had Matlab open a file named "Rotation.js"
Matlab wrote the lines into Rotation.js to create an open of a function... then it deposited the data array.
Then it wrote the lines to "close the function."
Then it closed the file.
Then I ran the *.html file that ran the thereJS code. The main.js called the function that Matlab created, and displayed the
results in 3D.
So... I know that is a silly thing to have done (I KNOW I could have coded in OpenGL, or written the javascript code to process
the data. But considering the complexity of the Runge-Kutta method on six differential equations, this was a good workaround.
What SHOULD I have asked to have gotten this result? Again, i am not asking for an answer or even a better way. I just want to know how I could have asked the question.
Here is the section from Matlab to show you what I did.fileID = fopen('get_RotationMatrix.js','w');
fprintf(fileID,'function get_RotationMatrix(){\n');
fprintf(fileID,'var rotation = [\n');
for i = 1:timeIntegrationSteps
fprintf(fileID,'\"%12.8f\",\n',omega1(i));
end
fprintf(fileID,'];\n');
fprintf(fileID,'return rotation;\n}\n');
fclose(fileID);
A few weeks ago (March 7) I asked how to have Javascript read a data file of numbers into an array.
I now understand why this is such a challenge when running a code on a web page, locally.
I have since found a sufficient workaround. I hope I can share it in the hope that someone can tell me how I SHOULD have asked the question. (Yes, this is an odd question: I am actually asking FOR a question.)
Here is what I did.
After Matlab processed all the numbers, I had Matlab open a file named "Rotation.js"
Matlab wrote the lines into Rotation.js to create an open of a function... then it deposited the data array.
Then it wrote the lines to "close the function."
Then it closed the file.
Then I ran the *.html file that ran the thereJS code. The main.js called the function that Matlab created, and displayed the
results in 3D.
So... I know that is a silly thing to have done (I KNOW I could have coded in OpenGL, or written the javascript code to process
the data. But considering the complexity of the Runge-Kutta method on six differential equations, this was a good workaround.
What SHOULD I have asked to have gotten this result? Again, i am not asking for an answer or even a better way. I just want to know how I could have asked the question.
Here is the section from Matlab to show you what I did.fileID = fopen('get_RotationMatrix.js','w');
fprintf(fileID,'function get_RotationMatrix(){\n');
fprintf(fileID,'var rotation = [\n');
for i = 1:timeIntegrationSteps
fprintf(fileID,'\"%12.8f\",\n',omega1(i));
end
fprintf(fileID,'];\n');
fprintf(fileID,'return rotation;\n}\n');
fclose(fileID);