필터 지우기
필터 지우기

export() live scripts not working

조회 수: 4 (최근 30일)
Phuwanut Pataratawinun
Phuwanut Pataratawinun 2022년 3월 18일
댓글: Walter Roberson 2022년 3월 18일
I tried to use this code to export multiple files in a folder, but it's not working:
Publish() works fine, but not export whose format I want.
clearvars
dirName = 'C:\Users\User\Desktop\NeedToExport\'
addpath(dirName)
files = dir(fullfile(dirName,'*.mlx'))
files = {files.name}'
for i = 1:length(files(:,1))
dirName = 'C:\Users\User\Desktop\NeedToExport\'
% This one is because the scripts have clearvars at the front and
% clears my variables for filenames
files = dir(fullfile(dirName,'*.mlx'))
files = {files.name}'
filename = files{i,1}
% filename = append(dirName,files{i,1})
% filenamepdf = append(filename(1:end-3),'pdf')
filename = convertCharsToStrings(filename)
% filenamepdf = convertCharsToStrings(filenamepdf)
path = export("Test.mlx")
path = export(filename)
end
  댓글 수: 2
Walter Roberson
Walter Roberson 2022년 3월 18일
If you create a new function to do the export() call, and pass the filename into that function, then any clearvars would only affect the workspace of the function, leaving your controlling script alone. You would still have a problem if the scripts contain clear all though.
Phuwanut Pataratawinun
Phuwanut Pataratawinun 2022년 3월 18일
편집: Phuwanut Pataratawinun 2022년 3월 18일
@Walter Roberson Thank you for the comment, but the main problem is the export() call doesn't work. Could you please tell me what did wrong? Publish() works fine, but it does not give the format that I want.
The tooltip says I need "obj", "rtcId", and "Options". I assume obj is the file name, and options is optional, but I cannot find any information about "rtcId".

댓글을 달려면 로그인하십시오.

답변 (2개)

Walter Roberson
Walter Roberson 2022년 3월 18일
files = dir(fullfile(dirName,'*.mlx'))
You use the folder information when you do the dir() but you only extract the name part of the result. You do not add the folder information onto the file name that you pass to export()
  댓글 수: 2
Phuwanut Pataratawinun
Phuwanut Pataratawinun 2022년 3월 18일
I still get "Check for incorrect argument data type or missing argument in call to function 'export'.".
Walter Roberson
Walter Roberson 2022년 3월 18일
What do you get if you ask
which export("test.mlx")

댓글을 달려면 로그인하십시오.


Steven Lord
Steven Lord 2022년 3월 18일
According to the Version History at the end of its documentation page, the export function that will "Convert live script or function to standard format" was "Introduced in R2022a". The release information on the right side of this question indicates you're using release R2021b. You will need to upgrade to release R2022a (or later, if you're reading this after release R2022b is released) to use this function.
  댓글 수: 1
Walter Roberson
Walter Roberson 2022년 3월 18일
Weird, version was one of the things I checked yesterday, and I thought I found it listed as introduced in R2021a...

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 C Shared Library Integration에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by