how to plot a contour plot with excel data??

33 visualizaciones (últimos 30 días)
sunitha
sunitha el 31 de Mzo. de 2021
Comentada: sunitha el 31 de Mzo. de 2021
I have to plot a contour plot for excel data. I have two variables x and y , and the individual variables contain 50 data ponts
i defined the data for the variables x and y
contour(x,y) ...i have written code but it is showing the error .can someone tell me where i did mistake ?
  5 comentarios
sunitha
sunitha el 31 de Mzo. de 2021
i have already calculated the output values and imported it in the excel .i have non linear equations from that i have calculated the variables
X=((bt*Qo*(1+R)*Xo)+(Y*a*V(i)*1000*J*bs))./(bt*((Qo*(1+R))-((V(i)*Y*k*N)/((Kn(i)*1000)+N))+(V(i)*kd)));
eqn1=(Qo*(1+R)*(No-N))-(V(i)*((a*J*1000)+((X*k*N)/((Kn(i)*1000)+N))));
eqn2=(sqrt((Lstar(i)^1.76)+(5.2*(Nstar-Nstar_min))-(Lstar(i)^0.88))/2.6)==jstar^0.88;
soln(i)=vpasolve([eqn1,eqn2],[N,J]);
i have these equations , now i varied the Kn parameter ,has 49 inputs corresponding to that i have calculated N, J variables.
now how i can plot contours for this non linear equation
??
sunitha
sunitha el 31 de Mzo. de 2021
should i vary the parameters two at a time and corresponding to that i have to plot this contours ??

Iniciar sesión para comentar.

Respuestas (2)

LO
LO el 31 de Mzo. de 2021
Editada: LO el 31 de Mzo. de 2021
from the folder containing your excel file run
the error about Z may be related to the fact that contour is waiting for a missing variable. But a turnaround is to give to the function an array directly (2D in this case).
Please edit the path to your file (remove the square brackets and put your file location).
%% Import the data
[~, ~, raw] = xlsread('[path to your file here]\contour gr.xlsx','Sheet1');
raw = raw(2:end,:);
%% Create output variable
data = reshape([raw{:}],size(raw));
%% Create table
contourgr = table;
%% Allocate imported array to column variable names
contourgr.ksmgcm3 = data(:,1);
contourgr.SmgL = data(:,2);
%% Clear temporary variables
clearvars data raw;
contour(table2array(contourgr));

Star Strider
Star Strider el 31 de Mzo. de 2021
I cannot see how to do a contour plot of two vectors that do not represent gridded data, since that does not make sense.
However one option could be:
D = readmatrix('contour gr.xlsx');
x = D(:,1);
y = D(:,2);
figure
contourf(x*y.')
.

Categorías

Más información sobre Contour Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by