Plot 2D contour graph with two variables.

I need to create a 2D contour plot for the data attached in excel sheet. I am also attaching a figure for reference. I want to plot RC1 against RC2 with their respective values.

7 Commenti

T = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1248612/Book1.xlsx') ;
RC1 = T.RC1 ;
RC2 = T.RC2 ;
val = T.Values ;
scatter(RC1,RC2,[],val,'filled')
What you have is a curve.....how you are expecting a plane?
There are two columns that has values. RC1 is to be plotted on x-axis against the values present in 2nd column. whereas, RC2 is to be plotted on y-axis against values present in 4th column of the excel sheet. it these are scatter plots, then there ashould be two trend lines here. I want to plot 2D conour plotswith RC1 and RC2 on x nd y-axis plotted agains ttheir corresponding values respectively.
So for row K you would plot at location x = RC1(K), y = RC2(K), z = column2(K), and column4(K) should be plotted in the 4th dimension??
That's what I am trying to comprehend. The graph attached has similar data that I have. I need to figure out if they have 4 dimensions. Any help in this regard is appreciated.
T = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1248612/Book1.xlsx') ;
RC1 = T.RC1 ;
RC2 = T.RC2 ;
col2 = T{:,2};
col4 = T{:,4};
mask = ismissing(RC1) | ismissing(RC2) | ismissing(col2) | ismissing(col4);
RC1(mask) = [];
RC2(mask) = [];
col2(mask) = [];
col4(mask) = [];
F2 = scatteredInterpolant(RC1, RC2, col2);
F4 = scatteredInterpolant(RC1, RC2, col4);
min1 = min(RC1); max1 = max(RC1);
min2 = min(RC2); max2 = max(RC2);
N = 150;
vec1 = linspace(min1, max1, N);
vec2 = linspace(min2, max2, N+1);
[G1, G2] = ndgrid(vec1, vec2);
Z2 = F2(G1, G2);
Z4 = F4(G1, G2);
subplot(3,1,1)
contourf(G1, G2, Z2); colorbar();
title('column 2')
subplot(3,1,2)
contourf(G1, G2, Z4); colorbar();
title('column 4')
subplot(3,1,3)
contourf(G1, G2, sqrt(Z2.^2 + Z4.^2)); colorbar()
title('wild guess - sqrt(sum of squares)')
Well, that wild guess didn't work out!
Or maybe even something as simple as
T = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1248612/Book1.xlsx') ;
% xdata and x-dependent vector
RC1 = T.RC1;
col2 = T{:,2};
% ydata and y-dependent vector
RC2 = T.RC2;
col4 = T{:,4};
% xdata is shorter; trim
mask = ismissing(RC1) | ismissing(col2);
RC1(mask) = [];
col2(mask) = [];
% col2 is invariant on y
% col4 is invariant on x
% combine the two as 2-norm?
z = sqrt((col2.').^2 + col4.^2);
contourf(RC1,RC2,z);
colorbar
???
Thank you for the guidance.
I have tried plotted it like this and this is what i get. I plotted both the data on x-axis and y-axis seperately. I need to combine these two outputs. please see the images atached.
T = readtable("RC1.xlsx");
convert = table2array(T);
contourf(convert)
colorbar
and then
T = readtable("RC2.xlsx");
convert = table2array(T);
contourf(convert)
colorbar

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Creating, Deleting, and Querying Graphics Objects in Centro assistenza e File Exchange

Prodotti

Richiesto:

il 1 Gen 2023

Commentato:

il 3 Gen 2023

Community Treasure Hunt

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

Start Hunting!

Translated by