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)

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 11 月 24 日
編集済み: Azzi Abdelmalek 2012 年 11 月 24 日

1 投票

You have brackets missing in your code
axis([0 2.5 100 -900

2 件のコメント

Ian
Ian 2012 年 11 月 24 日
wow, I can't believe I missed that, haha
Matt Fig
Matt Fig 2012 年 11 月 24 日
Good eye, Azzi! I was stumped at that error.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by