how to plot the graph
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
mohd akmal masud
il 8 Ago 2024
Commentato: Star Strider
il 8 Ago 2024
Hello Everyone,
I have some data as attached. Then I have the code to plot the graph. But I have to convert my file to excel first.
Anyway have that I can plot grpah wothout convert my file to excel?
clc
clear all
close all
spec=readlines('nema2.spe'); % read as text
whos spec
data=readmatrix('nema2.spe.xlsx'); %the data from point1.prn must export to excel first.
whos data
%then from excel, it can be plotted.
plot(data(:,1),data(:,2))
0 Commenti
Risposta accettata
Star Strider
il 8 Ago 2024
There is no need to convert it to Excel. It is only necessary to tell readmatrix (introduced in R2019a) that it is a text file, since that is not obvious from the file extension. Otherwise, readtable (inttroduced in R2013b) will work, with a minor modification to the readmatrix code.
Try this —
Uz = unzip('name2.zip')
A1 = readmatrix(Uz{1}, 'FileType','text')
x = A1(:,1);
y = A1(:,2);
figure
plot(x, y)
grid
T1 = readtable(Uz{1}, 'FileType','text')
x = T1{:,1};
y = T1{:,2};
figure
plot(x, y)
grid
.
4 Commenti
Star Strider
il 8 Ago 2024
@mohd akmal masud — As always, my pleasure!
To add axis labels to a 2D plot, use xlabel and ylabel, and to add a title, use title. (There are similar functions for 3D plots and groups of plots such as those produced by the tiledlayout function.)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!