how to plot the graph
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
mohd akmal masud
el 8 de Ag. de 2024
Comentada: Star Strider
el 8 de Ag. de 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 comentarios
Respuesta aceptada
Star Strider
el 8 de Ag. de 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 comentarios
Star Strider
el 8 de Ag. de 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.)
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!