Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.9K Views
|
5 Replies
|
4 Total Likes
View groups...
Share
Share this post:

[Solved] Loop a fourier calculation and export to csv-file

Posted 5 years ago

I want to evaluate the code below for a series of s, running s from for example 1 to 100, or with s being a list of specific numbers in a list such as {5,7,10, etc}. The result for each evaluation, thus for each individual s in the series, should be exported into a separate column in a csv file. In the attached notebook, as you see, I have set s to 5, thus exporting the resulting cosine projected 5000 steps into a single column csv. So far I have found the command Do: Do[sums, {s, list}] or Do[sums, {s, 100}], but then I have trouble incorporating the successive export for each s calculated.

The code/setup (also attached as a notebook file "test loop atco"): enter image description here

Any input appreciated! //Mike

Attachments:
POSTED BY: alltimetrader
5 Replies

Hi Mike, My approach: prior to the calculations, create a two dimensional empty table:

results = Table[Table[{}, columns], rows];

then after filling it with data, export it to a file name ending in .csv

Export[somePath <> "myresults.csv", results];

If you want a header row in your file:

resultsHeader = {col1label, ... };
Export[somePath <> "myresults.csv", Join[{resultsHeader}, results]];
POSTED BY: Richard Frost
Posted 5 years ago

Much appreciated! Perhaps your idea could be combined with the "Do" command to get the loop sorted but still seems uncertain to me how I implement that each s gets its own column until all calcs are done.

POSTED BY: alltimetrader
POSTED BY: Richard Frost
Posted 5 years ago
Attachments:
POSTED BY: Rohit Namjoshi
Posted 5 years ago

Wow Rohit. You made my day. Much obliged. Much to be learned..

Thanks!

//Mike

POSTED BY: alltimetrader
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard