Hi,
I need to make a 3D plot that change over time. I have 4 points which doesn't move in x and y, but z is moving through time. For exemple A(1,1,zA) B(1,2,zB) C(2,1,zC) and D(2,2,zD) and I have lots of values for zA, zB, zC, zD over time.
Who can I plot this in Matlab ?
Thank you for your answers.
Nicolas Harfaut

Antworten (3)

Star Strider
Star Strider am 14 Sep. 2016

2 Stimmen

You can probably adapt this code to do what you want:
[X,Y] = meshgrid(linspace(-5, 5, 50));
fcn = @(x,y,k) k*x.^2 + y.^2;
v = [1:-0.05:-1; -1:0.05:1];
for k1 = 1:2
for k2 = v(k1,:)
surfc(X, Y, fcn(X,Y,k2))
axis([-5 5 -5 5 -30 50])
drawnow
pause(0.1)
end
end

8 Kommentare

Nicolas harfaut
Nicolas harfaut am 15 Sep. 2016
This is exactly what I want to do, but the issue is that I don't have a function for "z" but juste data.
I have an excel spreadsheet where the first column is the time and the others are all the different data for the z component of my points over time. Do you know how I can include this in Matlab ?
Star Strider
Star Strider am 15 Sep. 2016
My ‘fcn’ function just calculates the z-data for the corresponding x- and y-grid points. Plotting data you have already acquired from a file should not be much different.
You can upload all or part of the file here using the ‘paperclip’ icon. It’s easier to write specific code with some — and preferably all (if there’s not too much) — of the actual data than to try to guess the content.
Nicolas harfaut
Nicolas harfaut am 19 Sep. 2016
Thank you for your answer, I uploaded my data on Matlab but I failed to plot it. I have a surface created with 25 points, all the x and y of the points are the same but the z data changes (I have 4000 values for z for each of my points depending on the time).
What I would like to do is to plot my 25 points as a moving surface where I can see all the z data changing at the same time in order to see my surface moving.
I am not sure if my explaination is understandable but if you can help me figure this out it will be amazing.
Thank you
Star Strider
Star Strider am 19 Sep. 2016
My pleasure.
I don’t see any attached files. I will download your file and work with your data when I have them. Please see Add Attachments, Images, and Links for details.
Nicolas harfaut
Nicolas harfaut am 5 Okt. 2016
Hi, Sorry for my late answer. I upload an excel sheet.
The idea is to plot the 4 points (A, B, C, D) in a 3D space (x, y, z) over time, for each point x and y don't move, but z moves over time.
Can you help me again ?
Best regards
Nicolas
Star Strider
Star Strider am 8 Okt. 2016
I’m not quite sure what you want.
Here are some possibilities with in the same loop, one (commented-out) is a straightforward plot, the other is a quiver3 version. The other plot is for my information.
It is of course not possible to plot in four dimensions (in this universe, at least) so this is my best effort:
[d,s,r] = xlsread('Nicolas harfaut Test 1.xls');
d_rng = [min(d(:,1:5)); max(d(:,1:5))];
figure(1)
plot(d(:,1), d(:,2))
hold on
for k1 = 3:5
plot(d(:,1), d(:,k1))
end
grid
legend('Az', 'Bz', 'Cz', 'Dz')
figure(2)
for k1 = 2:size(d,1)
quiver3(d(k1,2), d(k1,3),d(k1,4), mean(d(k1-1:k1,2)), mean(d(k1-1:k1,3)), mean(d(k1-1:k1,4)), 0, 'LineWidth',2)
% plot3(d(k1-1:k1,2), d(k1-1:k1,3), d(k1-1:k1,4), '-b.')
% axis([-10 15 -10 15 -10 15])
axis([-15 115 -15 115 -15 115])
grid on
drawnow
% refreshdata
end
Nicolas harfaut
Nicolas harfaut am 10 Okt. 2016
Thank you so much
Nicolas
Star Strider
Star Strider am 10 Okt. 2016
My pleasure.
If my Answer solved your problem, please Accept it.

Melden Sie sich an, um zu kommentieren.

KSSV
KSSV am 14 Sep. 2016

1 Stimme

clc; clear all ;
x = rand(4,1) ;
y = rand(4,1) ;
for i = 1:100
z = rand(4,1) ;
plot3(x,y,z) ;
drawnow
pause(0.2)
end
Nicolas harfaut
Nicolas harfaut am 15 Sep. 2016

0 Stimmen

Thank you for your answers, I wil look into it.
Nicolas Harfaut

Kategorien

Mehr zu Graphics Performance finden Sie in Hilfe-Center und File Exchange

Produkte

Gefragt:

am 14 Sep. 2016

Kommentiert:

am 10 Okt. 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by