Matlab issues with plotting a variable
Mostrar comentarios más antiguos
Hello,
I have a csv file that I would like to take 2 columns from and make them x and y axis. I managed to plot one of the columns however the other column always gives me an error whenever I try to plot with it. I attached the data file below. Here is my code:
intel_cpus=readtable('intel.csv');
C=intel_cpus.("Cores");
E = intel_cpus.("BaseSpeed");
plot(C,'.')
I am trying to get columns D and F as axis of my graph. Thank you for any help!
1 comentario
Mathieu NOE
el 17 de Mayo de 2021
hello
I noticed that the csv file as not same number of separators in all lines (separator = comma)
see the result in the table will right shift some fields

this is also obvious when you convert inot xlsx file with comma separator
need some cleaning first ...
Respuesta aceptada
Más respuestas (1)
I think you want to remove the characters after the floating values. You cannot plot the values with the units attached.
While it might not be the cleanest, you could just go for:
D = str2double(replace(intel_cpus.("MaxTurboSpeed"),{' GHz',' MHz'},''));
and
E = str2double(replace(intel_cpus.("BaseSpeed"),{' GHz',' MHz'},''));
F = str2double(replace(intel_cpus.("CacheSize"),{' MB'},''));
Please do remember to add some code to keep the unit info regarding giga and mega.
I assume you are using this for something like an overview, so it should be fine.
Categorías
Más información sobre Language Fundamentals en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
