문제

I have a .txt file with cylindrical coordinates, theta, x (would be rho in matlab) and z, all in numbers. I am trying to convert them into cartesian coordinates and then plot them (mesh or surf). I imported the txt file and i have now 3 variables theta,x,z. I used the command [x,y,z] = pol2cart (theta, x, z) but the result is a one column only.

Where I am wrong?

The datas are in columns separated by a blank space:

10.2837 -99.975 36.8826
10.2837 -99.963 36.8826
10.2837 -99.95  36.8826
10.2837 -99.938 36.8826
도움이 되었습니까?

해결책

How can you get a "one column only" output when you specify three output variables. Do you get an error message?

Have you managed to get your data into a matrix? (As a Matlab variable, not a text-file with spaces?) If so, try:

data_mat = [10.2837 -99.975 36.8826
            10.2837 -99.963 36.8826
            10.2837 -99.95  36.8826
            10.2837 -99.938 36.8826];

%% Assuming this order is correct:
theta = data_mat(:,1);
rho = data_mat(:,2);
zz = data_mat(:,3);

[x, y, z] = pol2cart(theta, rho, zz);

Also, remember to transform your angles into radians.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top