필터 지우기
필터 지우기

How to write a script to analyse data files

조회 수: 12 (최근 30일)
Niklas Reinshagen
Niklas Reinshagen 2020년 6월 16일
댓글: Niklas Reinshagen 2020년 6월 18일
Hi I have a major issue,
I try to write a script wich just needs the name of a file in a specific Directory (in my case xxx.neu files from a GPS System) and just shows me a graph.
In general I do this in command Window:
load ana1CleanUnf.neu
plot (ana1CleanUnf)
This is very easy. My first intention to write a script to automate this was:
function x = getGPSstats('*.neu')
x = load '*.neu'
x = plot ('*.neu')
end
but this gives my an error:
Error: File: getGPSstats.m Line: 1 Column: 26
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets
instead of parentheses.
Well I really don't know how to fix this, I try so long but really don't get it.
  댓글 수: 1
Niklas Reinshagen
Niklas Reinshagen 2020년 6월 16일
I forgot to mention, that I got about 10 .neu Files. And want to save the script in the folder, so I can just plot them with one line of code.

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

채택된 답변

Rik
Rik 2020년 6월 16일
You can use dir to retrieve all the file names. And since you don't actually use the input of your function, I don't see why you would keep that.
I would also suggest writing a bit more robust code to load your data. This way the data magically appears in your workspace and it is difficult to track where each variable is coming from.
  댓글 수: 8
Rik
Rik 2020년 6월 17일
getGPSstats('ana1CleanUnf.neu');
function x = getGPSstats(name)
% The first command is to navigate
% to the directory with the files
cd ~/Desktop/UNI/Matlab/Ex4_Data
%now load the requested file 'name.neu'
x = load (name);
% and finally plot it
plot (x)
end
Even like that?
Niklas Reinshagen
Niklas Reinshagen 2020년 6월 18일
Thank you! It was the semikolon ath the End of the function to call it, now everything works fine!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by