Reproduce electric motor maps as images in Matlab Simulink
Mostrar comentarios más antiguos
Hello dear community,
I need your help to solve a small problem I am facing in my internship. I have a YASA 750 electric motor map that I found in a data sheet (attached) and I would like you to extract the iso-efficiency curves (torque, speed and efficiency) and reproduce them in Matlab. Is there a tool that can allow me to do this?
15 comentarios
There are a number of tools for transcribing graphs from images. This post lists a few.
Doing that would get you a set of x,y vectors for each curve. You could interpolate from there.
I have a feeling that trying to do this automatically via image processing is going to be a complete mess. The jpg compression is going to mess up line extraction significantly enough that the close-packed sections are going to need to be manually transcribed anyway. Trying to extract the heatmap by relying on the colorbar is similarly defeated by the gross chroma distortion in the image. Anything extracted that way would be very noisy and likely distorted in ways that are less obvious than extracting the level curves.
If it were me, I'd probably try to use one of the digitizer webapps, or I'd throw it into a vector graphics program, trace it out with bezier curves, and then export each curve as an image, import that image into Matlab, and run [x,y]=find(thiscurve) or somesuch.
Akram SLIMANI
el 9 de Abr. de 2021
Editada: Akram SLIMANI
el 9 de Abr. de 2021
DGM
el 9 de Abr. de 2021
Consider the test:
I used inkscape to generate the following images by tracing over the plot with a bezier curve tool.

I can then import them into Matlab
inpict = rgb2gray(imread('curve88.png'))>127;
inpict = bwmorph(inpict,'thin',20);
[y88,x88] = find(flipud(inpict));
x88 = x88./size(inpict,2)*3250;
inpict = rgb2gray(imread('curve90.png'))>127;
inpict = bwmorph(inpict,'thin',20);
[y90,x90] = find(flipud(inpict));
x90 = x90./size(inpict,2)*3250;
clf
scatter(x88,y88,'.'); hold on;
scatter(x90,y90,'.');

Of course, this is just scattered XY data. It'll have to be interpolated somehow.
Akram SLIMANI
el 9 de Abr. de 2021
DGM
el 9 de Abr. de 2021
Each of these curves is a locus of constant efficiency. The curves are the level curves of a surface whose height is efficiency. In the process of importing curves from manually extracted data, you'll end up with only x and y data. The efficiency is constant (e.g. 88% and 90% for the two curves shown). All you need is a constant vector z of the same length as x and y. If you want to try to interpolate to get a full surface, you could then concatenate the vectors for all the curves and then use griddata on them.
In case you're still working on digitizing, I went ahead and did this demo with the curves:
% find the apex of the curve
whichx = x88;
whichy = y88;
[~,idx] = min(whichx);
topmask = whichy>=whichy(idx);
% split the curve in half
xt = whichx(topmask);
yt = whichy(topmask);
xb = whichx(~topmask);
yb = whichy(~topmask);
% reduce/sort/reorient/concatenate
[xt,idx,~] = unique(xt);
yt = yt(idx);
[xb,idx,~] = unique(xb);
xb = flipud(xb);
yb = flipud(yb(idx));
x = [xb; xt];
y = [yb; yt];
% plot
plot(x,y); hold on

This will give correctly ordered vectors (as opposed to scattered data). If you're more interested in extracting the surface (as opposed to the curves themselves), sorting may not be necessary.
Akram SLIMANI
el 9 de Abr. de 2021
Akram SLIMANI
el 13 de Abr. de 2021
Editada: Akram SLIMANI
el 13 de Abr. de 2021
DGM
el 13 de Abr. de 2021
If you have a single curve from that plot and you've scaled the x and y data to speed and torque, then all of those speed and torque values correspond to the same efficiency.
If what you mean is to find the efficiency for points in between the curves, then you'll need to interpolate between curves. This could be done with griddata() or probably scatteredInterpolant().
Both of these methods work with scattered inputs, so like I said, they don't need the curves to be refined. Depending on how you're able to arrange things, there may be other ways. You should be able to concatenate the vectors for the curves and use either. I'm not sure how accurate these methods are going to be toward the center-right area of the plot where the slope is shallow and the curves are open. If you're looking at points between the curves, it should behave better.
Akram SLIMANI
el 14 de Abr. de 2021
Slimani Akram
el 19 de Abr. de 2021
Please DGM, I have another question that bothered me a lot:
Actually, i have two picture: one that illustrate power as a function of time and another one speed over time. So, i have extract two excel files and what i want is to match these two files to have a picture with power versus speed. How can i do that in Matlab, please?
Slimani Akram
el 19 de Abr. de 2021
These are the excel files that i am talking about : puissance_Z1G (time A:A, power B:B) and vitesse_Z1G (time A:A,speed B:B)
Slimani Akram
el 19 de Abr. de 2021
Editada: Slimani Akram
el 19 de Abr. de 2021
I have managed to do that :
clc;
clear all;
tp=xlsread('puissance_Z1G.csv','A:A');
p=xlsread('puissance_Z1G.csv','B:B');
tv=xlsread('vitesse_Z1G.csv','A:A');
pv = interp1(tp,p, tv, 'linear', 'extrap')
plot(tp,p,'r',tv,pv,'b')
Thanks very much DGM for your openness to help many people of this large community in Matlab !!!!!!
Akram SLIMANI
el 23 de Abr. de 2021
Editada: Akram SLIMANI
el 23 de Abr. de 2021
Pat Gipper
el 25 de Abr. de 2021
I also see there are some community apps intended to do what you ask. I haven't looked into the one I show here but it will give you a notion that the need is recognized.
https://www.mathworks.com/matlabcentral/fileexchange/49009-image-digitizer?s_tid=srchtitle
Akram SLIMANI
el 25 de Abr. de 2021
Editada: Akram SLIMANI
el 25 de Abr. de 2021
Respuestas (1)
Pat Gipper
el 25 de Abr. de 2021
0 votos
A similar question was answered suggesting importing the image into Matlab and then using ginput to extract coordinates of the axes and desired curve in the picture reference coordinate system. The last step involving "correspondence matching" is a bit vague.
https://www.mathworks.com/matlabcentral/answers/95486-how-do-i-extract-x-and-y-data-from-a-printed-picture-of-a-2d-line-plot-that-i-have-scanned-and-i#answer_104839
2 comentarios
Akram SLIMANI
el 25 de Abr. de 2021
Pat Gipper
el 25 de Abr. de 2021
My pleasure. I also wanted to suggest looking into Community Apps on File Exchange. This link below might help you.
https://www.mathworks.com/matlabcentral/fileexchange/49009-image-digitizer?s_tid=srchtitle
Categorías
Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!