Correct scale of printed pdf Simulink models - matlab

Hi I'm trying to print some simulinks models to use them on a latex document.
I've checked the documentation and the posts in stackoverflow and found some answers but they didn't solve my problem.
I want to create a script to print several models with their correct scaling, so I used the commands:
set_param('model','PaperPositionMode','tiled')
set_param('model','ShowPageBoundaries','on')
set_param('model','PaperType','A4')
set_param('model','TiledPageScale','2')
print -dpdf -r300 -smodel model.pdf
When I change the TiledPageScale value I see the change in Simulink, but when I print the file either on pdf or eps the result is cropped the same as with TiledPageScale 1, no matter what value I've set.
I've checked the answer Save Matlab Simulink Model as PDF with tight bounding box but I'm using matlab 2014a so I don't know if it's fixed yet
Thanks
EDIT: I'd ask or comment in the above post but I don't have the enough reputation

Related

Matlab - OCR function digits recognition

Recently I'm trying to detect digits from images in Matlab and I encountered a problem: a clear visible '1' on photo below (and many similar)
1
is not detected by 'ocr' function. Could you tell me how can I preprocess this image to allow this funcion recognize such a numbers?
you might find this example on the mathworks web-site helpful. The second example of looking for digits on a picture of calculator is particularly relevant.
Applying the first trick they use (telling OCR you are expecting a block of text) results in the code below; which I found partially worked with the particular example image you linked above.
% Load your image
I = imread('tkTMN.jpg');
% Perform OCR, looking for a block of text:
results = ocr(I, 'TextLayout', 'Block');
% Display the recognized words
if ~isempty(results.Words)
disp(results.Words);
else
error('no words found');
end
For me, on matlab 8.6.0.267246 (R2015b) this returned the word list:
'1'
'.'
'j'
So not perfect, but at least it found the '1'. The other pre-processing tricks suggested on the mathworks page might get you better results.

How to create the approximately equal mark in MATLAB

I want to create the approximately equal mark in the legend of the MATLAB. And it will show correctly, but when I try to export the plot by saveas (gca,'1.eps','psc2'). Then in the file, the approximately equal mark will be error code.
MATLAB legend(), title(), xlabel() and ylabel() functions interpret tex commands by default. A quick search suggests \approx or \cong as possible symbols to try. If it works, could you update your question with before and after examples?
This is what I have in mind
figure
title('Pi \approx 3.14')
or
title('Pi \cong 3.14')
See here for more details of MATLAB tex interpretation.

Savefig not found

I am new to Matlab and trying to save my current figure to file. So, I have followed the official documentation at http://www.mathworks.co.uk/help/matlab/ref/savefig.html#inputarg_h and entered the following into Matlab:
figure;
surf(peaks);
savefig('PeaksFile.fig');
close(gcf);
However, I get the following error:
Undefined function 'savefig' for input arguments of type 'char'.
If I type in:
help savefig
I get the following error:
savefig not found.
Any ideas on what's going on? I would have thought that savefig comes with all releases of Matlab rather than requiring any add-ons. The version of my Matlab is 2013a.
It looks as though savefig is not implemented in Matlab version earlier than 2013b (from some experimentation and a comment at the end of http://www.mathworks.com/matlabcentral/fileexchange/10889-savefig). Instead, use saveas(h,'filename.ext'), which is documented here http://www.mathworks.co.uk/help/matlab/ref/saveas.html and is certainly included in 2012a.
You're using R2013a, while savefig was released in R2013b. I can't test if the functionality is identical as I don't have R2013b (or newer) on this computer, but you might try the savefig-function on the File Exchange, or other alternatives available in the R2013a-release.
The two answers are great. Another option which I believe has been around for many, many years is to use the print command:
print -f1 -djpeg bob.jpg
The -f1 is the figure number and obviously bob.jpg is the filename to which you want to write. I have code going back to 2007 using that but I am sure it goes back earlier than that. So it should work with pretty much any version you are using.
For that matter, using print, you can write PS, EPS, TIFF, PNG as well as JPG.

How to export the output of a SOM in MATLAB

Ok, so this question is related to my ongoing task of getting text data categorized, you can refer to this question for more details on how I approached this problem.
I used the standard matlab function "nctool" (neural clustering tool) to get my inputs organized on a plane of 10x10 SOM nodes. I also got the output of this map (i.e. which of my inputs ended up on which node) saved in to the "output" variable in my workspace.
I would now like to get this data out and see if I can write another script. I'm aware of the 'save' and some of the export functions in MATLAB, however it seems that MATLAB does not support ascii export of this variable since it is a sparse matrix.
I am currently writing a script to get this thing exported out, however if someone already has a solution, please post. Otherwise I will do so after I finish testing it.
Update: I found a workaround to this fairly easily:
% convert a sparse matrix to full
output = full(output);
% output this to a file (excel)
xlswrite('test.csv',output);

display the output from mat file

Please, any one help me: how can I display the output (image file name, mean color image, color histogarm) to see it, which I saved it in sruct of array in mat file
You can load mat files (MatLAB) formats in the free software GNU Octave.
Loading it would give you a new variable, let's say a
After you loaded it, you can display it according to the structure using octave commands.
GNU octave can be downloaded here: http://www.gnu.org/software/octave/download.html
Example hist(a)