Changing Dimension from <1x3x100> t0 <3x100> in matlab

Status
Not open for further replies.

illegal121

Member level 2
Joined
Jun 20, 2011
Messages
49
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Oman
Activity points
1,650
hello friends ...

here is my simple code..

Code:
for i=1:100
    pause(0.05)
  y(:,:,i)=i+rand(1,3)
end

it generates "y" like this on command window

Code:
y(:,:,1) =

    1.4091    1.4740    1.9090


y(:,:,2) =

    2.5962    2.3290    2.4782
.
.
.
.
y(:,:,100) =

  100.1526  100.8330  100.1919

and finally after the loop finishes y has a dimension on workspace <1x3x100 double> with class double now the problem is that I CAN'T PLOT MY FINAL ARRAY DUE TO ITS DIMENSION I WANT THIS ARRAY DIMENSION TO BE <3x100> any alternate way to do this ....

PLEASEEEEE HELP....!
 

Kindly use this
Code:
y=zeros(3,100);
for i=1:100
[INDENT]y(:,i)=i+rand(3,1);[/INDENT]
end
 

yeah that's rite I had already tried this one too but the problem is that it is not working for my script i.e

Code:
fid=fopen('file.txt');
fseek(fid,81,'bof')
for i=1:40
A=fgetl(fid)
 A = str2num(A)
end
fclose(fid);

I am getting A from here
Code:
A=fgetl(fid)

If i changed it to
Code:
A(i,:)=fgetl(fid)

So it will give error
sub scripted assignment mismatch
Because the data in the file is character class ...
Now...? :sad:
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…