How do I create surface between curves of differing amounts of data points
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am trying to plot curves in seperate planes and draw surfaces connecting them. so far i have managed this with;
x1=linspace(0, pi, 100)
x2=linspace(0, pi, 100)
z1=sin(x1)
z2=sin(x2)
k1=ones(1, length(x1))
k2=2*ones(1, length(x2))
plot3(k1, x1, z1); hold on; plot3(k2, x2, k2)
surf([k1;k2], [x1;x2], [z1;z2], 'meshstyle', 'row')
However, the surf function isnt working when I create x2 and x1 with differing numbers of data points such as;
x1=linspace(0, pi, 50)
x2=linspace(0, pi, 25)
Thurthermore any way to smooth the boundaries of the curves would be greatly appreciated as im am very new to this. Thanks in advance.
0 Commenti
Risposte (1)
Tony
il 2 Lug 2024
Modificato: Tony
il 2 Lug 2024
One method is to expand to use the union of reference data points, and then apply the two functions to the union reference
x1=linspace(0, pi, 50);
x2=linspace(0, pi, 25);
x12 = unique([x1 x2]);
z1=sin(x12);
z2=sin(x12);
k1=ones(1, length(x12));
k2=2*ones(1, length(x12));
figure(1); tiledlayout(1, 2);
nexttile; plot3(k1, x12, z1); hold on; plot3(k2, x12, z2);
nexttile; surf([k1;k2], [x12;x12], [z1;z2], 'meshstyle', 'row');
But if you don't have the original function, you can interpolate the data
x1=linspace(0, pi, 50);
x2=linspace(0, pi, 25);
z1=sin(x1);
z2=sin(x2);
x12 = unique([x1 x2]);
z1_12 = interp1(x1, z1, x12);
z2_12 = interp1(x2, z2, x12);
k1=ones(1, length(x12));
k2=2*ones(1, length(x12));
figure(2); tiledlayout(1, 2);
nexttile; plot3(k1, x12, z1_12); hold on; plot3(k2, x12, z2_12);
nexttile; surf([k1;k2], [x12;x12], [z1_12;z2_12], 'meshstyle', 'row');
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!