## Recommended Posts

jakiś kodzik od czerwonych?

##### Share on other sites

czerwoni:

x = [-3:0.01:3];

y = fun2(x);

figure(1);

plot(x,y,'r');

title("Fun1");

xlabel('x');

ylabel('y');

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

##### Share on other sites

a czxarni cos mają?

czarni help

##### Share on other sites

jak zapisac to n+2/2^n+2 + 1 w octave

tą jedną linijke

##### Share on other sites

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

##### Share on other sites

Sprawdzi ktoś czy dobrze liczy?

xp=2;

xk=10;

tol=3;

function [y]=fun1(x)

y=(sin(4.*x))./x;

end

##### Share on other sites

%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')

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

%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);

#### Archived

This topic is now archived and is closed to further replies.

×