Filter löschen
Filter löschen

3D plotting of known data

4 Ansichten (letzte 30 Tage)
Bill Murray
Bill Murray am 27 Jun. 2022
Kommentiert: William Rose am 13 Jul. 2022
I'm trying to plot a 3D graph, which shows time vs bus number vs voltage (pu). The latter has a minimum and maximum value.
The following is an example of the data.
time (1...24hours)
bus number (1....10)
voltage (pu) - bus 1 = 0.93(min), 1.056(max), bus 2 = 0.926(min), 1.063(max), ... up to 10 buses

Akzeptierte Antwort

William Rose
William Rose am 27 Jun. 2022
Generate sample data: ten sinusoidal voltage records, with random variation in amplitude and frequency:
t=0:.5:24;
v=(rand(10,1)-.5).*cos((1+rand(10,1))*t);
Plot the traces as ten 2D records, on one plot:
figure; plot(t,v(1,:),'-ro',t,v(2,:),'-go',t,v(3,:),'-bo') %v1 to v3
hold on;
plot(t,v(4,:),'-rx',t,v(5,:),'-gx',t,v(6,:),'-bx') %v4 to v6
plot(t,v(7,:),'-r+',t,v(8,:),'-g+',t,v(9,:),'-b+',t,v(10,:),'-r*')
legend('Bus 1','Bus 2','Bus 3','Bus 4','Bus 5','Bus 6','Bus 7','Bus 8','Bus 9','Bus 10');
If you want paralell plots that looks three dimensional, you could do
bus=(1:10)'.*ones(size(v)); %create array with the bus numbers
figure; %new figure for plotting
plot3(t,bus(1,:),v(1,:),'-ro',t,bus(2,:),v(2,:),'-go',t,bus(3,:),v(3,:),'-bo') %v1,v2,v3
grid on; hold on;
plot3(t,bus(4,:),v(4,:),'-rx',t,bus(5,:),v(5,:),'-gx',t,bus(6,:),v(6,:),'-bx') %v4,v5,v6
legend('Bus 1','Bus 2','Bus 3','Bus 4','Bus 5','Bus 6'); %add legend
xlabel('Time'); ylabel('Bus'); zlabel('Voltage'); %add axis labels
You can click and drag on the plot above, to rotate it. Obviously, you could add a line of code for v7 to v10. Or you could use a for loop that loops over i=1:10 to do all ten. Try it. Good luck.
  11 Kommentare
Bill Murray
Bill Murray am 3 Jul. 2022
I managed to resolve the problem.
The only concern is the image resolution when inserting the saved imaged in Word.
William Rose
William Rose am 4 Jul. 2022
@Bill Murray, thnk you for accepting the answer. I am not sure how to improve the image resolution in word. Of course there are many ways to import into word nd they offer different potential resolutions.
Once you have created the figure, you can click File -> Save As. Window pops up, and a the bottom there is a "Save as file type" option, with 14 possible file formats to save as. I am sure that some of those formats will import well into word. I usually use jpg and it looks good to me wen I import to Word for a manuscript submission.
Another method is to make the figure as large as possible on screen, then taking a screen shot, which you can save as jpg or png or various other formats, depending on your screenshot app. Then you import the sceenshot.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Bill Murray
Bill Murray am 4 Jul. 2022
Thanks for the response. The best resolution is enhanced metafile (emf) but as I said the image is completely distorted.
Please advise how I change the bus identification numbers from 1-10 eg 701,711,741,750,etc
  1 Kommentar
William Rose
William Rose am 13 Jul. 2022
I am sorry to hear that theimage is completely distorted. I have had good luck with the screen capure program SnagIt. I bought a personal copy over 5 years ago, never upgraded, and it still works. I can capture a plot that is on my screen and save it in any number of formats. It also comes with an image editing program, with a lot of capabilities, that lets me touch up an image. Usually I save as jpeg. Then I import the image into Word when I compose a manuscript.
To change the bus labels from (1 to 10) to a set of arbitrary numbers, append the following commands to the code I posted earlier:
xlim([1,10]); %axis limits=[1,10] instead of the default [0,10]
xticks(bus); %make ticks at 1,2,3,...,10
xticklabels({'701','711','741','750','752','757','767','777','787','799'});
The produces the plot below. By the way, I saved this plot as a jpeg file with the SnagIt program, so that I could upload it to this answer box.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by