<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
Dear Natálie,
<div><br>
</div>
<div>Perhaps the following may be helpful:</div>
<div><br>
</div>
<div><a href="https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.fieldtriptoolbox.org%2Ffaq%2Fpreproc%2Fdatahandling%2Fconvert_dataformat%2F&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C55e126f8477642a02f0c08dde5ff1be1%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638919606030284504%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=I3xqQhkthtSp2%2Fth0FBTRZalw%2FjLEIGrWo%2BBen1Xq2A%3D&reserved=0" originalsrc="https://www.fieldtriptoolbox.org/faq/preproc/datahandling/convert_dataformat/">https://www.fieldtriptoolbox.org/faq/preproc/datahandling/convert_dataformat/</a><br id="lineBreakAtBeginningOfMessage">
<div><br>
</div>
<div>Long story short: I think you need to call ft_write_data(filename, data_to_save.trial{1}, …), i.e. the second argument into the function should be a numeric matrix, not a data structure.</div>
<div><br>
</div>
<div>I agree that the received error message is a bit cryptic. It would be nice if somebody took up the challenge to build a ‘check’ early into ft_write_data to verify that the dat variable is a matrix and/or make the docstring a bit more informative (nudge,
nudge to the reader). </div>
<div><br>
</div>
<div><br>
</div>
<div>Best wishes,</div>
<div>Jan-Mathijs</div>
<div><br>
</div>
<div><br>
<blockquote type="cite">
<div>On 26 Aug 2025, at 18:43, Natalie via fieldtrip <fieldtrip@science.ru.nl> wrote:</div>
<br class="Apple-interchange-newline">
<div>
<div>
<div>Hi all,</div>
<div><br>
</div>
<div>I would really appreciate your help with the error below. I keep getting it after fix trials. I uploaded the script as well.</div>
<div><br>
</div>
<li>
<p><b>The exact error message</b>:</p>
</li><li>Forcing data to be real and of class double before saving...<br>
Error using write_edf (line 58)<br>
Cannot write complex-valued data<br>
<br>
Error in ft_write_data (line 745)<br>
write_edf(filename, hdr, dat);<br>
<br>
</li><li>
<p><b>My MATLAB version: </b>MATLAB Version: 9.8.0.1323502 (R2020a)</p>
</li><li>
<p><b>My FieldTrip version: </b>stating that it is "revision unknown", downloaded on 11.08.2025</p>
</li><li>
<p><b>My operating system: </b>Microsoft Windows 10 Pro Version 10.0 (Build 19045)</p>
</li><br>
Thank you for any help.<br>
<br>
<div>Kind Regards,</div>
<div>Natálie Šejvlová</div>
<br>
</div>
<span id="cid:D48141EC-D8FB-4F63-B885-AF7927826AE1"><Untitled.m></span>_______________________________________________<br>
fieldtrip mailing list<br>
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip<br>
https://doi.org/10.1371/journal.pcbi.1002202<br>
</div>
</blockquote>
</div>
<br>
</div>
</body>
</html>