Attempt to reference field of non-structure array.
1 次查看(过去 30 天)
显示 更早的评论
I'm trying to read and load the .mat data (originally from .csv files) as following code;
input_data=xlsread('input_data_test.xlsx',1,'(B14:E18)');
[nofinput]=length(input_data(:,1));
start=input('press enter to start');
for ww=1:nofinput;
ii=input_data(ww,:);
if ii(isfinite(ii(:, 1)), :);
run_1=ii;
CA=run_1(1,1)
CA_CA=CA;
x_first=run_1(1,2)
y_first=run_1(1,3)
z_first=run_1(1,4)
step_number=5
[uu]=step_number;
[cc]=26;
AAA=zeros(uu,cc);
clear uu cc
Speed=1600;
Delta_CA=0.25
Time_CA=(60/Speed)/360
Delta_t=Delta_CA*Time_CA;
load CA0000.mat
load CA0025.mat
load CA0050.mat
for tt=1:step_number
if CA==0 matrice_cartesian=CA0000.mat;
elseif CA==0.25 matrice_cartesian=CA0025.mat;
elseif CA==0.5 matrice_cartesian=CA0050.mat;
end
but there's an error message; "Attempt to reference field of non-structure array" at line "elseif CA==0.25 matrice_cartesian=CA0025.mat;" So what is the possible cause for this problem? Please help, I'm really newbie in MATLAB code. Thanks
1 个评论
Walter Roberson
2016-11-24
Is
matrice_cartesian=CA0000.mat
intended to indicate that matrice_cartesian should be assigned the string 'CA0000.mat' or that it should be assigned what is stored in the file CA0000.mat ?
采纳的回答
Walter Roberson
2016-11-24
My guess:
if CA==0 matrice_cartesian=CA0000;
elseif CA==0.25 matrice_cartesian=CA0025;
elseif CA==0.5 matrice_cartesian=CA0050;
end
However, you should be avoiding exact comparison of floating point values. The values 0.25 and 0.5 are exactly representable in floating point but the value that is in CA might have been calculated by a process that did not result in exactly 0.25 or exactly 0.5
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!