Problem with fopen - not a valid target for assignment
显示 更早的评论
I am using fopen to try to read multiple files, but it fails to open the second file. My error reads "The expression to the left of the equals sign is not a valid target for assignment" at the second fid = fopen statement. I have tried changing the variable name to no avail. I am not sure what I can do to fix this, please help!
fid = fopen('padlockposition.txt');
position = zeros(1000,3);
for i = 1:1000
line = fgetl(fid);
position(i,1) = str2double(line(1:7));
position(i,2) = str2double(line(9:16));
if numel(line) == 26
position(i,3) = 0;
elseif numel(line) == 29
position(i,3) = str2double(line(25:29));
else
position(i,3) = position(i-1,3);
end
end
figure(1)
plot(position(:,1)-226.2,position(:,2),position(:,1)-226.2,position(:,3))
axis([0 2.5 100 -900
fclose(fid);
fid = fopen('padlockpid.txt');
pid = zeros(1000,2);
(the program will continue from here once I figure out this problem)
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Low-Level File I/O 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!