필터 지우기
필터 지우기

How can I replace eval and rewrite the below line?

조회 수: 1 (최근 30일)
Harini pushparaj
Harini pushparaj 2017년 11월 1일
댓글: OCDER 2017년 11월 1일
Hi..How can I replace eval..when I tried this way
Speed =Data.(cycle_name(1:end-4)).Data;
Time=Time.(cycle_name(1:end-4)).Time;
it is giving me some error saying Undefined variable "Data" or class "Data.FTP.Data".
eval(['Speed = ' cycle_name(1:end-4) '.Data;']);
eval(['Time = ' cycle_name(1:end-4) '.Time;']);
  댓글 수: 2
Stephen23
Stephen23 2017년 11월 1일
The solution will be to load your data properly, into an output variable (which happens to be a structure). If you want help with this then please edit your question and upload a sample .mat file so that we can check our code on your data.
Harini pushparaj
Harini pushparaj 2017년 11월 1일
Hi ..I am attaching both FTP file and the code

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

답변 (1개)

OCDER
OCDER 2017년 11월 1일
편집: OCDER 2017년 11월 1일
NEW ANSWER:
Inside the FTP.mat is a variable called ts storing the timeseries object. To access the contents inside ts, do this:
Z = load(fullfile('..\cycledata',cycle_name)) % Z is a temporary variable
Speed = Z.ts.Data;
Time = Z.ts.Time;
OLD ANSWER:
Assuming you have a non-scalar structure called cycle_name that has at least 5 elements, this should work:
Speed = cycle_name(1:end-4).Data;
Time = cycle_name(1:end-4).Time;
  댓글 수: 16
Harini pushparaj
Harini pushparaj 2017년 11월 1일
I have only one FTP file..its the same ...
OCDER
OCDER 2017년 11월 1일
Starting from the beginning... Set your working directory to the folder storing FTP.mat. Then do this:
clear
load('FTP.mat')
Do you atleast get ts variable show up in your workspace?
Note that "..\cycledata\FTP.mat" means go to the folder above the current directory, then to cycledata folder, then the FTP.mat file inside there. My hunch is, there is another FTP.mat file, just not in your current directory that you want.
The FTP.mat file you showed in the screenshot picture DOES show the ts variable.
HOWEVER, the result from whos command does not show the ts variable, and instead show a variable called FTP that is the timeseries. Hence, it seems you are not loading the correct .mat file.

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

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by