Input coordinates cannot be complex.
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Christabelle Tonna
am 3 Aug. 2019
Kommentiert: Star Strider
am 3 Aug. 2019
I am trying to calculate the surface area of a plot generated using surf. I am using the function surfarea attached. I keep getting the error Input coordinates cannot be complex when executing griddata. None of the coordinates in the file are complex. The file is too large to attach so I am including an extract image. The file is downloadable at https://we.tl/t-mfKxV2RFQ3 . Can anyone indicate a potential reason please?
clc;
clear variables;
T=readtable('C:\Users\CT\Desktop\Matlab Question\Surface.dat');
x=T(:,1);
y=T(:,2);
z=T(:,3);
[X,Y] = meshgrid(0:1:2455, 0:1:1848);
Z = griddata(x,y,z,X,Y);
h = surf(X,Y,Z);
[totalArea] = surfarea(h);
shading interp;
xlabel('x'), ylabel('y'), zlabel('z'),colorbar
title(sprintf('Total surface area: %.2f', surfarea(h)));
view(60,30);
saveas(h, 'C:\Users\CT\Desktop\Matlab Question\Surface.png');
Update:
The code works fine when using
T=xlsread('C:\Users\CT\Desktop\Matlab Question\Surface.xlsx', 1);
instead of readtable. However I cannot import data from Excel as the original data file contains 10.9 million rows.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 3 Aug. 2019
If you can read the entire file with readtable and you simply want the data in the table, consider using the table2array function to convert your table columns to a double array.
I have no idea what the problem could be with complex values and griddata, especially if your code works with xlsread.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!