plot the graph of mulivariable

18 visualizzazioni (ultimi 30 giorni)
shiv gaur
shiv gaur il 13 Gen 2022
Modificato: Walter Roberson il 26 Feb 2025 alle 4:53
theta = linspace(0,2*pi,100);
na= linspace(1,20,100);
da= linspace(0,5,100);
figure(1)
[x,y]=f(theta,na,da);
dx = gradient(x);
dy = gradient(y);
dna=gradient(na);
p=dy./dx/dy./dna;
plot(da,p);
Warning: Imaginary parts of complex X and/or Y arguments ignored.
%%%%%%%%%%%%%%%%%%%
function [x,y]=f(theta,na,da)
np=1.5;
a=1.2;
b=3;
x=np*sin(theta);
k1=sqrt(a-x.^2)+na;
k2=sqrt(b-x.^2);
y=(k1-k2)./(k1+k2)+da;
end
pl help to plot graph between da vs p=dy/dx/dy/dna
  2 Commenti
shiv gaur
shiv gaur il 13 Gen 2022
pl help to plot graph between da vs p=dy/dx/dy/dna
Benjamin Thompson
Benjamin Thompson il 28 Gen 2022
y and dy have complex values due to x being to large. Can you change the definition of your problem?

Accedi per commentare.

Risposte (1)

Vedant
Vedant il 26 Feb 2025 alle 4:08
Upon reviewing your code, I noticed that the expression for p should be written as
p = (dy ./ dx) ./ (dy ./ dna)
instead of
p = dy./dx/dy./dna
This ensures the correct order of division and prevents ambiguous results.
Also, as the “p” will contain both real and imaginary parts so create the plot of them as below:
figure;
subplot(2, 1, 1);
plot(da, real(p));
xlabel('da');
ylabel('Real part of p');
title('Real Part of da vs p');
grid on;
subplot(2, 1, 2);
plot(da, imag(p));
xlabel('da');
ylabel('Imaginary part of p');
title('Imaginary Part of da vs p');
grid on;
After implementing the changes, the final result of plotting this graph is as follows:

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Tag

Prodotti


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by