The code only works on Evaluation
Show older comments
This code only when run normally, N_id, N_x, N_y and N_z will give me nothing. But when i used Evaluate on the codes. It actually work, but i am not sure why
FileName = ['C:\Users\ying0018\Desktop\Right Femur\Surface_Baseline_R.inp']
disp('*******************************************************************************************************')
disp(['Current Directory: ', FileName]);
disp('*******************************************************************************************************')
fid = fopen(FileName);
SWData = textscan (fid, '%s', 'delimiter', '\n', 'whitespace', '');
SWStr = SWData{1};
NBD = strfind(SWStr,'*NODE');
Node_begin = find(~cellfun('isempty', NBD));
NED = strfind(SWStr, '**HWCOLOR COMP ');
Node_end = find(~cellfun('isempty', NED));
Node_range = (Node_end - (Node_begin + 1));
% ND : Node data, N: Nodess
ND = textscan(fid,'%d %f %f %f', Node_range,'delimiter',',','headerlines', Node_begin, 'CommentStyle','**');
N_Id = ND{1,1};
N_x = ND{1,2};
N_y = ND{1,3};
N_z = ND{1,4};
Nodes = [N_Id, N_x, N_y, N_z];
6 Comments
Walter Roberson
on 17 Nov 2017
Difficult to say without a copy of your input file.
Also, what does it mean to use Evaluate in this context?
Yann Yiing
on 17 Nov 2017
Yann Yiing
on 17 Nov 2017
Walter Roberson
on 17 Nov 2017
You can zip the inp file and attach the zip
Walter Roberson
on 17 Nov 2017
What name did you give to the file that the code is stored in?
Yann Yiing
on 17 Nov 2017
Accepted Answer
More Answers (0)
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!