converting vector result into matrices for surf command
조회 수: 13 (최근 30일)
이전 댓글 표시
Hello,in a program there is feald on aplane shown bellow.
the field data was exports and i am trying to recreate this fiels in matlab.
I have a problem where the exported tablable is show in the attached file ,the resulthas a vector as a result.
in surf command i needthe IMAGEEy result be a matrix
its folding every 24 members.
how can i recreate the photo of the progrm thanks?
I tried the photo shown bellow and it gave me gibrish
rows=(with.zmm==48.394400000000000);
data=with(rows,:);
x=data.xmm(1:24);
y=data.ymm;
y2=y(1:24:240);
z=reshape(data.EyImVm,24,[]);
[yy,xx]=meshgrid(x,y2)
surf(xx',yy',z)
댓글 수: 0
답변 (2개)
Walter Roberson
2022년 11월 20일
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1200898/with.txt';
with = readtable(filename);
with.Properties.VariableNames = {'xmm', 'ymm', 'zmm', 'ExReVm', 'ExImVm', 'EyReVm', 'EyImVm', 'EzReVm', 'EzImVm'};
rows = ismembertol(with.zmm,48.394400000000000);
data = with(rows,:);
x = data.xmm(1:24);
y = data.ymm;
y2 = y(1:24:240);
z = reshape(data.EyImVm,24,[]);
[yy, xx] = meshgrid(x, y2);
surf(xx',yy',z)
xlabel('x'); ylabel('y'); zlabel('EyImVm');
Star Strider
2022년 11월 20일
I have no idea what you want to plot.
Use the first two column (that correspond to ‘x’ and ‘y’ respectively), the choose whatever other column you want, and use scatter3 to plot them. m There is no need to reshape them.
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1200898/with.txt')
x = T1{:,1};
y = T1{:,2};
z = T1{:,3};
Eyv = T1{:,6};
figure
scatter3(x, y, z, 10, z, 'filled')
grid on
colormap(turbo)
view(30,20)
figure
scatter3(x, y, Eyv, 10, Eyv, 'filled')
grid on
colormap(turbo)
view(30,20)
Experiment to get the desired result.
.
댓글 수: 6
Walter Roberson
2022년 11월 22일
A line, maybe? Constant z and constant y over a source that is a grid of data would still leave open the possibility of a line graph, EyImVm vs x ?
Star Strider
2022년 11월 22일
Certainly! Although some sort of scatter plot is at the base of this. The surface — if one exists — evolves from that. I just don’t understand how to get there from the provided data.
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!