Input coordinates cannot be complex.
15 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Christabelle Tonna
il 3 Ago 2019
Commentato: Star Strider
il 3 Ago 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 Commenti
Risposta accettata
Star Strider
il 3 Ago 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Surface and Mesh Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!