andrzeju56 Posted June 8, 2017 Report Share Posted June 8, 2017 jakiś kodzik od czerwonych? Link to comment Share on other sites More sharing options...
petrus Posted June 8, 2017 Report Share Posted June 8, 2017 czerwoni: disp("# Zad 1") x = [-3:0.01:3]; y = fun2(x); figure(1); plot(x,y,'r'); title("Fun1"); xlabel('x'); ylabel('y'); disp("# Zad 2") x = 1; s = 0; m = 4.8; i = 0; while(s < m) i = i + 1; x = i*sqrt(i+3)/2^i; s = s + x; end indeks = i wynik = s function [y] = fun2(x) s = size(x); s = s(2); for i=1:s if x(i) < 0 y(i) = sin(3*x(i)); else y(i) = x(i)^3 ./ atan(x(i)); end end endfunction Link to comment Share on other sites More sharing options...
andrzeju56 Posted June 8, 2017 Report Share Posted June 8, 2017 a czxarni cos mają? Link to comment Share on other sites More sharing options...
andrzeju56 Posted June 8, 2017 Report Share Posted June 8, 2017 czarni help Link to comment Share on other sites More sharing options...
andrzeju56 Posted June 8, 2017 Report Share Posted June 8, 2017 jak zapisac to n+2/2^n+2 + 1 w octave tą jedną linijke Link to comment Share on other sites More sharing options...
DonKaktus Posted June 8, 2017 Report Share Posted June 8, 2017 Próbowałem zrobić pare programów, sprawdzi ktoś czy są błędy? x1=-2:0.001:0; x2=0:0.001:2; y1=sin(1./x1); y2=x2*0; %plot(x1,y1,'r',x2,y2,'b') clear n=0; w=0; s=0; m=0.01; do w=(2^n)/(factorial(n)); s=s+w; n=n+1; until w<m s n clear display(' ') display(' ') n=0; w=0; s=0; m=6; do w=(2^n)/(factorial(n)); s=s+w; n=n+1; until s>m w n clear display(' ') display(' ') A=[1 2 3;4 5 6;7 8 9] [k]=macierzz(A) [k]=macierzz2(A) display(' ') display(' ') a=2; b=10; n=11; h=(b-a)/n; x=a:h:b; y=(sin(4.*x))./x; calka=(h/2)*(y(1)+y(n+1)+2*sum(y(2:n))) function[k]=macierzz(A) ii=1; jj=1; k=0; x=rows(A); do k=k+A(ii,jj); ii=ii+1; jj=jj+1; until ii>x ii=x; jj=1; do k=k+A(ii,jj); ii=ii-1; jj=jj+1; until jj>x if mod(x,2)==1 x=ceil(x/2); k=k-A(x,x); endif endfunction function[k]=macierzz2(A) ii=1; jj=1; k=0; z=0; x=rows(A); for ii=1:x for jj=1:z k=k+A(ii,jj); endfor z=z+1; endfor endfunction Link to comment Share on other sites More sharing options...
atakujacy Posted June 9, 2017 Report Share Posted June 9, 2017 Sprawdzi ktoś czy dobrze liczy? xp=2; xk=10; tol=3; quad('fun1',xp,xk,tol) function [y]=fun1(x) y=(sin(4.*x))./x; end Link to comment Share on other sites More sharing options...
celestial_being Posted June 9, 2017 Report Share Posted June 9, 2017 zadanko 1 %zad1 %x=input('Podaj x:'); x1=-2:0.01:0; x2=0:0.01:2; y1=sin(1./x1); y2=0.*x2; plot(x1,y1,'r',x2,y2,'b') zadanko 2 %zad2 s=0; i=0; m=0.01; x=1; n=1; while(x>=m) i=i+1; n=n*i x=(2^i)./n s=s+x; endwhile i s zadanko 3 %zad3 %x:[1, 2, 3; 4, 5, 6; 7, 8, 9] x=input('Podaj macierz x:'); ii=1; jj=1; suma=0; [w,s]=size(x); while (ii<=w) while(jj<=w) spraw=ii+jj-1; if ((spraw==w) || (ii==jj)) suma=suma+x(ii,jj); disp(suma); endif jj=jj+1; endwhile jj=1; ii=ii+1; endwhile disp(suma); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.