Prev: Copying data from 1 excel file into another
Next: XlimMode = 'manual' overridden by subsequent plot?
From: Giedrius Jevstignejevas on 15 Jun 2010 11:23 function [w, m]=fm(a,z) % fm programa funkcijos m, w reiksmems apskaiciuoti % a - konstanta % z - funkcijos argumentas, vektoriaus eilute % w - funkcijos w reiksmes, vektoriaus eilute % m - funkcijos m reiksmes, vektoriaus eilute %--------------------------------------------------------------- [m,n]=size (z); for i=1:n w(i)=a(i)*abs(sin(cos(z(i)))); if z(i)<2 m(i)=sin(z(i))/(2-z(i)); elseif (z(i)>=2)&(z(i)<5) m(i)=sqrt(z(i))/(1+z(i)); elseif z(i)>=5 m(i)= sin(2*z(i))-1; end end; % pagrindiniu reiksmiu priskirimas a=4; z0=-2.1; zn=2.1; zh=0.2; %w vektoriaus reiksmiu formavimas z=z0:zh:zn; % w ir m reiksmiu apskaiciavimas [m, n]=size(z); disp('Funkciju reiksmiu lentele'); disp(' z w m '); [z' w' m' ] %grafiko formavimas [f] = fm(a,z); a=-4; [f1] = fm(a,z); plot(z,f,z,f1); grid on; >> labor1 Funkciju reiksmiu lentele z w m ??? Error using ==> horzcat All matrices on a row in the bracketed expression must have the same number of rows. Error in ==> C:\MATLAB6p1\work\labor1.m On line 12 ==> [z' w' m' ] what is wrong ?
From: Jan Simon on 15 Jun 2010 11:51
Dear Giedrius! > ??? Error using ==> horzcat > All matrices on a row in the bracketed expression must have the > same number of rows. > > Error in ==> C:\MATLAB6p1\work\labor1.m > On line 12 ==> [z' w' m' ] Use the debugger: dbstop if error Then the execution stops when an error appears and you can inspect the variables in the workspace: size(z) size(w) size(m) Now you see, why you cannot concatenate them after transposing. Good luck, Jan |