[英]use JavaScript to create a .mat file
我正在開發一個插件(用於Grafana,一個用於分析和監視的開放平台, https: //grafana.com/),並且為了簡化數據分析,我希望允許該插件的用戶下載。 Mat文件直接來自Grafana。 但是,我無法在我的JavaScript代碼中創建正確的.mat文件。 我嘗試了以下方法:
<button onclick="download('file text', 'myfilename.mat', 'text/plain')"><a href=""
id="a">click here to download your file</a>Create file</button>
<script>
function download(text, name, type) {
var a = document.getElementById("a");
var file = new Blob([text], {type: type});
a.href = URL.createObjectURL(file);
a.download = name;
}
</script>
從JavaScript:創建並保存文件 。 但是,以這種方式創建的.mat文件會出現錯誤:
在ASCII文件C:\\ Users \\ Esmee \\ Downloads \\ myfilename(2).mat“ file”的第1行上使用加載未知文本時出錯。
uiimport / runImportdata(第459行)中的錯誤datastruct = load('-ascii',fileAbsolutePath);
uiimport / gatherFilePreviewData中的錯誤(第427行)[datastruct,textDelimiter,headerLines] = runImportdata(fileAbsolutePath,type);
uiimport中的錯誤(第244行)collectFilePreviewData(fileAbsolutePath);
我不知道該怎么辦。 我認為問題在於,僅將字符串“文件文本”放入.mat文件中並不是MATLAB通常使用的文件語法。 有沒有人有使用Javascript / html創建.mat文件的經驗,還是有人知道該文件應采用哪種格式才能在MATLAB中可讀?
提前致謝!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.