I have recently joined MATLAB Online. I wanted to use Gaussian surface fit for my data and regarding which I have found file exchange (FEX). When I checked them, they had a function file but I am facing trouble as how to use those functions on my own data.
I searched for this simple thing but I could not find about it anywhere.
Thank you

댓글 수: 1

Stephen23
Stephen23 2023년 12월 19일
편집: Stephen23 2023년 12월 19일
"How to use function(s) in FEX?"
Code that is available on FEX is no different to your own code. You use it in exactly the same way: by having it on the MATLAB Search Path (e.g. the simplest and easiest is to have it in your current directory) and then calling it.
An alternative to downlolading the ZIP file is to use: https://www.mathworks.com/products/matlab/add-on-explorer.html

댓글을 달려면 로그인하십시오.

 채택된 답변

Dyuman Joshi
Dyuman Joshi 2023년 12월 19일

0 개 추천

Download the FEX submission, which will be downloaded as a zip file.
Extract the contents in a folder. Move the folder to the current directory of MALTAB, and then run your code. Make sure you call the function properly.
Enter "cd" in the command window to check the current directory.

댓글 수: 3

Deepshikha Deo
Deepshikha Deo 2023년 12월 19일
I have already downloaded the zip file and uploaded it to my MATLAB drive though I did not change the current directory. But I had added the data (double type) (size: 4834x1) in the workspace and basically copy-pasted the code of the function in the script, it still didn't work.
Can you explain give me an example. Suppose I have a 4834x3 size csv file (that has xy coordinates and z values) and the 'gaussfitn' (by Matt J), then how should I use this data and the function? What should be the code to call the function for my data?
The line below is used to declare the function and according to the comments added only 'xdata' and 'zdata' are required and rest of parameters are optional. Thus, I am trying to add my data of coordinates to 'xdata' and z-values to 'zdata' but failing to do so.
function [params,varargout] = gaussfitn(xdata,zdata,params0, lbCell, ubCell,varargin)
Thank you
Stephen23
Stephen23 2023년 12월 19일
편집: Stephen23 2023년 12월 19일
"basically copy-pasted the code of the function in the script"
Do NOT copy and paste the entire function code into a script. Just call the function they provided you with! Make sure that the downloaded FEX code is on your MATLAB Search Path (e.g. in your current directory).
Import your data using e.g. READMATRIX or READTABLE, then select the columns you want using indexing or variable/column names.
Then call the function (after reading its documentation carefully to know what inputs it requires), e.g.:
X = your X array
Y = your Z array
P = gaussfitn(X,Z)
Deepshikha Deo
Deepshikha Deo 2023년 12월 21일
Thank you for your help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 File Operations에 대해 자세히 알아보기

질문:

2023년 12월 19일

댓글:

2023년 12월 21일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by