Skip to content
View in the app

A better way to browse. Learn more.

Forum PSX Extreme

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Problem z kodem

Featured Replies

Możecie drodzy kąsolowcy sprawdzić czy ten kod z Matlaba jest prawidłowy jest to kod na zaliczenie i bardzo mi zleży aby działał. Liczę na waszą pomoc

 

clc, clear

fprintf('program tablicuje wybrane (programowo) wartości funkcji elementarnych\n');

fprintf('y1(x)=x^2\n y2(x)=x^3\n y3(x)=e^x\n')

fprintf('dla x w zakresie <xp;xk> z krokiem delx oraz oblicza sumę tablicowanych wartości funcji w kolumnach\n')

xp=input('xp=');

xk=input('xk=');

delx=input('delx=');

nazwa=input('nazwa pliku wyników: ','s');

s1=0; s2=0; s3=0; % zerujemy sumy

i=1 %definiujemy indeks startowy wektorów y1, y2, y3 i x

x(i)=xp; % nadajemy pierwszą wartość x-owi

plik=fopen(nazwa,'w'); %zakładamy plik

fprintf(plik,'Tablicowanie wartości wybranych funcji elementarnych w zakresie od xp do xk co delx.\r\nJednocześnie obliczanie sumy tablicowanych funcji w kolumnach.\r\n');

fprintf(plik,'\r\nDane:\r\n');

fprintf(plik,%5s %8.3f\r\n','delx=',delx);

fprintf(plik,%5s %8.3f\r\n','delx=',delx);

fprintf(plik,%5s %8.3f\r\n\r\n','delx=',delx);

fprintf('\n%6s %12s %12s %12s %12s\n\n','Lp','x','x^2','x^3','e^x');

fprintf(plik,'%6s %12s %12s %12s %12s\r\n\r\n','Lp','x','x^2','x^3','e^x');

while x(i)<=xk

y1(i)=x(i)^2;

y2(i)=x(i)^3;

y3(i)=exp(x(i));

fprintf('%6d %12.3f %12.3f %12.3f %12.3e\n',i,x(i),y1(i),y2(i),y3(i);

fprintf(plik,'%6d %12.3f %12.3f %12.3f %12.3e\r\n',i,x(i),y1(i),y2(i),y3(i));

if x(i)+delx>xk % dodatkowy warunek

break % przerwanie pętli while

end

x(i+1)=x(i)+denx;

i=i+1

end

s1=sum(y1); s2=sum(y2); s3=sum(y3);

fprintf('\n');

fprintf(' Suma(x^2)= %12.3f\n',s1);

fprintf(' Suma(x^3)= %12.3f\n',s2);

fprintf(' Suma(e^x)= %12.3e\n',s3);

fprintf(plik,'\r\n');

fprintf(plik,' Suma(x^2)= %12.3f\n',s1);

fprintf(plik,' Suma(x^3)= %12.3f\n',s2);

fprintf(plik,' Suma(e^x)= %12.3e\n',s3);

fclose(plik); %zamknięcie pliku wyników

clf

subplot(1,3,1)

plot(x,y1)

xlabel('x[-]'), ylabel('y[-]'), legend('y=x^2')

subplot(1,3,2)

plot(x,y2)

xlabel('x[-]'), ylabel('y[-]'), legend('y=x^3')

subplot(1,3,3)

plot(x,y3)

xlabel('x[-]'), ylabel('y[-]'), legend('y=e^x')

  • Views 1.3k
  • Created
  • Last Reply

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.