how to plot using surf function?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi
I am using this code as attached in my file and I am struggling with getting markers as circles; I dont find anything on properties tool that I can change to get markers as circles and not a line.
test %Matt J inserted so we can see result of running the attachment
1 commentaire
Matt J
le 31 Juil 2022
Your attached code doesn't generate anything currently, as the Run ouput that I inserted for you demonstrates.
Réponses (2)
David Hill
le 31 Juil 2022
You only have 3 points. z would need to be a matrix to use surf.
osmotisk_data = readtable("tester_tabeller.xlsx");
x = osmotisk_data{:,3};
y = osmotisk_data{:,1};
z = osmotisk_data{:,2};
plot3(x,y,z)
2 commentaires
dpb
le 31 Juil 2022
Modifié(e) : dpb
le 31 Juil 2022
Not from that m-file and data, not possible.
>> type test.m
osmotisk_data = readtable("tester_tabeller.xlsx");
x = osmotisk_data{:,3};
y = osmotisk_data{:,1};
z = osmotisk_data{:,2};
surf(X, Y, Z, Z )
colorbar
% grid on
>> test
Unrecognized function or variable 'X'.
Error in test (line 7)
surf(X, Y, Z, Z )
>>
As the comment in Answer below noted, the surf command uses uppercase variable names instead of the defined lowercase ones used in extracting the data from the table.
There's the problem in using scripts -- there must be some OTHER set of X,Y,Z in your workspace different than the x,y,z you just defined from the read data file.
If then use the actual variable names instead, then
>> surf(X, Y, Z, Z )
Unrecognized function or variable 'X'.
Did you mean:
>> surf(x, y, z, z )
Error using surf (line 71)
Z must be a matrix, not a scalar or vector.
>>
which is @David Hill's point -- and "No, you canNOT have only a vector for surf; you've got to have a full 2D array of a value for every x,y pair -- in this case that would require a 3x3 array since there are three values for each x and y.
dpb
le 31 Juil 2022
Modifié(e) : dpb
le 31 Juil 2022
osmotisk_data = readtable("tester_tabeller.xlsx");
x = osmotisk_data{:,3};
y = osmotisk_data{:,1};
z = osmotisk_data{:,2};
surf(X, Y, Z, Z )
I don't know what else one would expect from such code??? Tries to plot uppercase variables but defined lowercase ones instead.
And, there's nothing in call to surf that will set the marker style to anything but the default which by the documentation is 'none' and to set/turn the linestyle off.
surf(x,y,z,'linestyle','none','marker','o')
1 commentaire
dpb
le 31 Juil 2022
Of course, the above assumes the data are commensurate with the need to have a 2D array for Z which isn't so (and can't be so out of a table as constructed; one would have to build the 2D array to match.
Voir également
Catégories
En savoir plus sur Graphics Object Programming dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!