Path fo file MATLAB - matlab

I began using MatLab and faced problem with setting up path.
%% Set path and file name %Set main folder
defaultFolder=fileparts(fileparts(mfilename('/Users/s2986149/Desktop/MTP/Exported_STL_files/scaphoid_lunate_sl_ligament_smooth.stl')));
pathName=fullfile(defaultFolder,'MTP','Exported_STL_files');
% File name for STL
fileName=fullfile(pathName,'scaphoid_lunate_sl_ligament_smooth.stl');
%% Import a txt type STL file as patch data
[stlStruct] = import_STL(fileName);
Error using textscan
Invalid file identifier. Use fopen to generate a valid file identifier.
Error in txtfile2cell (line 16)
T=textscan(fid,'%s','delimiter', '\n','Whitespace','');
Error in import_STL (line 16)
T=txtfile2cell(fileName);
Error in Meshing (line 17)
[stlStruct] = import_STL(fileName);
In the terminal
$ pwd
/Users/s2986149/Desktop/MTP/Exported_STL_files
Thanks in advance
NataCalc

Related

How do I fix bugs while executing matlab standalone applications?

Hello stackoverflow community,
I am currently trying to create a Matlab application as a standalone application. In Matlab, the program runs fine via the GUI, however, as soon as I install the application on my desktop and run it, I get the following error messages output to the command window:
Error using dicom_getFileDetails (line 14)
Unable to load file "RE.#_STR_IMG.REGISTRATION.dcm".
Error in dicominfo (line 55)
Error in Apply_Registration/ApplyRegistrationButtonPushed (line 64)
Error in appdesigner.internal.service.AppManagementService/tryCallback (line 333)
Error in matlab.apps.AppBase>#(source,event)tryCallback(appdesigner.internal.service.AppManagementService.instance(),app,callback,requiresEventData,event) (line 35)
Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 335)
Error while evaluating button PrivateButtonPushedFcn.
Code:
1+2)
% Button pushed function: OpenRegistrationFileButton
function OpenRegistrationFileButtonPushed(app, event)
% Open registration file
app.File_registrationFile = uigetfile;
end
reginfo = dicominfo(app.File_registrationFile);
What is the problem when running as a standalone application?
The Matlab Runtime Compiler matches my Matlab version. Unfortunately, I lack the expertise to move forward here.
Any help will be greatly appreciated!
You are currently only outputting the file name from uigetfile (docs), so subsequent usage of that file assume it's in the same folder as the executing app. This is likely not the case, hence the error that the file can't be loaded (because it doesn't exist).
You just need to be more explicit, get the path too and refer to the full file path instead of just the name
[file,path] = uigetfile;
app.File_registrationFile = fullfile( path, file );

Error in loading a .mat file in jupyter notebook

I am facing a setback while loading a .mat file in jupyter notebook. Here's the issue encountered:
#import mat4py
from scipy.io import loadmat
mat = loadmat('Dog_1_ictal_segment_1.mat')
Error: TypeError: Expecting miMATRIX type here, got 3225714032
The mat file is downloaded from UPenn and Mayo's competition hosted at Kaggle, https://www.kaggle.com/c/seizure-detection/data.
I don't have access to the original matlab file, and I am not sure if the same was saved under v7.3+ release. Can anyone please guide me on this?
On matlab try:
fid = fopen('Dog_1_ictal_segment_1.mat');
txt = char(fread(fid,[1,140],'*char'));
fclose(fid);
disp(txt)
I get MATLAB 5.0 MAT-file for Patient_8_ictal_segment_1.mat (same competition). When using -v7.3 the header should start with MATLAB 7.3 MAT-file. I was able to load the data to python with no error using your code.
Possibly your data is corrupt, try downloading it.

Matlab error for interface script

I'm using ksvdbox for my research. After installing as guided in Readme, I run ksvddemo. I throws the following error:
Attempt to execute SCRIPT sprow as a function:
C:\Users\thdo\Documents\MATLAB\ClassificationV2\ClassificationV2\ksvdbox\private_ccode\sprow.m
Error in ksvd>optimize_atom (line 515)
[gamma_j, data_indices] = sprow(Gamma, j);
Error in ksvd (line 449)
[D(:,p(j)),gamma_j,data_indices,unused_sigs,replaced_atoms] = optimize_atom(data,D,p(j),Gamma,unused_sigs,replaced_atoms);
Error in ksvddemo (line 74)
[Dksvd,g,err] = ksvd(params,'verbose');
In ksvdbox, there is a script named "sprow.m" but there is no code inside this file, only comments. In fact, there is another file named "sprow.c" in the same folder. I tried to rename "sprow.m" but it throws another error:
Underfined function or variable 'sprow'
The interesting thing is that the code works for Matlab2014a, but the errors happen on Matlab2015b.
Could you please suggest me a solution?

TMG Matlab Error

when I connect MATLAB & MYSQL ,the Error is
init_tmg ================================================================================================== ================================================================================================== You are about to installed the TMG Toolbox to you system. Press any key to continue! ================================================================================================== ================================================================================================== Is MATLAB Database Toolbox installed (yes/no)?: yes Is MySQL installed (yes/no)?: yes Please give the full path to the MySQL Java Connector (jar file): C:\Program Files (x86)\MySQL\Connector J 5.1.23\mysql-connector-java-5.1.23-bin.jar ??? Error using ==> fprintf Invalid file identifier. Use fopen to generate a valid file identifier.
Error in ==> init_tmg at 36 fid=fopen(strcat(matlabroot, filesep, 'toolbox', filesep, 'local', filesep, 'classpath.txt'), 'a'); fprintf(fid, '\n%s', str); fclose(fid);
How can I Deal with this Error????
i was facing the same, but solved this :
step1 : copying the mysql-connector-java-5.1.23-bin.jar file to the c:/programfile/matlab/R2012aStudent/toolbox/local
step2: In the "Please give the full path to the MySQL Java Connector (jar file) :" just provide the file name which is "mysql-connector-java-5.1.23-bin.jar"
no need to give the full path in my case because by default it checks the file in the "c:/programfile/matlab/R2012aStudent/toolbox/local " folder

compilemex in Statistical Pattern Recognition Toolbox in Matlab

I am new to Statistical Pattern Recognition Toolbox in matlab.
I am trying to use the oaasvm function in this toolbox. Before using this I need to run the compilemex.m. But when I run it I get the following error
>> compilemex
Compiling MEX files of STPRtool...
mex -O -IC:\Program Files\MATLAB\R2013a\toolbox\stprtool\kernels -outdir C:\Program Files\MATLAB\R2013a\toolbox\stprtool\kernels C:\Program Files\MATLAB\R2013a\toolbox\stprtool\kernels\kernel.c C:\Program Files\MATLAB\R2013a\toolbox\stprtool\kernels\kernel_fun.c
Error using mex (line 206)
The destination directory "C:\Program" cannot be found.
Error in compilemex (line 113)
eval(mexstr);
Can anyone tell how shall I proceed to run the oaasvm code?
As explained by Schorsch in the comments, you need to add quotes around path strings to handle spaces in them.
The fix is easy, edit the file compilemex.m, look for the following section (line 102), and make the below changes:
% -- Compile functions -----------------------------
for i=1:length(fun),
mexstr = ['mex -O -I''' translate(fun(i).include,root) ...
''' -outdir ''' translate(fun(i).outdir, root) ''' '];
for j=1:length(fun(i).source),
mexstr = [mexstr '''' translate(char(fun(i).source(j)),root) ''' '];
end
fprintf('%s\n',mexstr);
eval(mexstr);
end
Basically I've added single quotes (escaped by singe quote) around path strings. The result is that the commands executed will be of the form:
mex -O -I'C:\Documents and Settings\Amro\Desktop\stprtool\kernels'
-outdir 'C:\Documents and Settings\Amro\Desktop\stprtool\kernels'
'C:\Documents and Settings\Amro\Desktop\stprtool\kernels\kernel.c'
'C:\Documents and Settings\Amro\Desktop\stprtool\kernels\kernel_fun.c'
Note that you dont have to place this package inside the MATLAB installation. You can place the extracted folder anywhere on your system, as long as you add it to the MATLAB path addpath