Storing volatile data in Flash Memory

I'm using an Arduino Mega ADK, which has 256kB of flash memory.

I would like to be able to store a 32kB array in flash memory. I can send this data to the arduino through the serial port from matlab. Ideally I would like to send the data from matlab, store it in the flash memory for a little while and access it as I please, then replace it with another 32kB block.

I realize that I could use external memory parts and they would probably be faster and what not, but that's not what I'm interested in. I would like to keep circuit complexity to an absolute minimum and being able to store volatile data in flash memory would be very useful.

Is there any way of doing this?

Thanks!

I'm using an Arduino Mega ADK, which has 256kB of flash memory.

Otherwise known as program memory, which is read-only at run time.

I would like to be able to store a 32kB array in flash memory.

You can.

I can send this data to the arduino through the serial port from matlab.

Ooh, not that way, though.

So this is not possible?

My sketch is currently able to recieve data from matlab via the Serial.readBytes() command. I currently only read 1kB at a time, then send it to a DAC.

I'm just looking to send all the data at once and store it in program memory then access and change it while my sketch is still running.

I'm just looking to send all the data at once and store it in program memory

That is the part you can't do.

Only option I can think of is to use an external memory module. May I suggest buying an SD card module (like the one Adafruit sells), hooking it up and then using Serial.read() and saving all the data to the card and after all the data is on the card, then access it through your program. Total cost around 20 USD and you can have gigabytes of storage.