https://jp.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — 新規の質問2021-02-27T01:03:22Ztag:jp.mathworks.com,2005:Question/7549492021-02-24T14:58:40Z2021-02-27T01:03:22ZUnable to compile model for Simulink real timeI want to use the Simulink real time.
My Simulink model contains a C S-function file. Namely FAST_SFunc. The code like follows (1).
The S-function can be used for simulation, but when it is used for Simulink real time, an error is reported after clicking the "build model" button as follows (2).
The problem can be reproduced through the compressed package in the attachment. I'm r2018b and vs2017 15.0。
https://github.com/sanluoruge/FAST_COMPILE.git
I don't have the corresponding TLC file. Is that the reason why I can't compile? Is there any good solution?
Thanks
(1) FAST_SFunc ↓
/*
* TEMPLATE File: sfuntmpl_gate_fortran.c
* TEMPLATE Copyright 1990-2013 The MathWorks, Inc.
*
* Modified by B. Jonkman, National Renewable Energy Laboratory
* for use with FAST v8
* 20-Jan-2015
*/
/*
* You must specify the S_FUNCTION_NAME as the name of your S-function
* (i.e. replace sfungate with the name of your S-function, which has
* to match the name of the final mex file, e.g., if the S_FUNCTION_NAME
* is my_sfuntmpl_gate_fortran, the mex filename will have to be
* my_sfuntmpl_gate_fortran.mexXXX where XXX is the 3 letter
* mex extension code for your platform).
*/
#define S_FUNCTION_LEVEL 2
#define S_FUNCTION_NAME FAST_SFunc
/*
* Need to include simstruc.h for the definition of the SimStruct and
* its associated macro definitions.
*/
#include "simstruc.h"
#include "mex.h" // for mexPutVariable
#include "matrix.h" // for mxCreateDoubleScalar
#include "FAST_Library.h"
#define PARAM_FILENAME 0
#define PARAM_TMAX 1
#define PARAM_ADDINPUTS 2
#define NUM_PARAM 3
// two DWork arrays:
#define WORKARY_OUTPUT 0
#define WORKARY_INPUT 1
static double dt = 0;
static double TMax = 0;
static int NumInputs = NumFixedInputs;
static int NumAddInputs = 0; // number of additional inputs
static int NumOutputs = 1;
static int ErrStat = 0;
static char ErrMsg[INTERFACE_STRING_LENGTH]; // make sure this is the same size as IntfStrLen in FAST_Library.f90
static char InputFileName[INTERFACE_STRING_LENGTH]; // make sure this is the same size as IntfStrLen in FAST_Library.f90
static int n_t_global = -2; // counter to determine which fixed-step simulation time we are at currently (start at -2 for initialization)
// function definitions
static int checkError(SimStruct *S);
static void mdlTerminate(SimStruct *S); // defined here so I can call it from checkError
static void getInputs(SimStruct *S, double *InputAry);
static void setOutputs(SimStruct *S, double *OutputAry);
/* Error handling
* --------------
*
* You should use the following technique to report errors encountered within
* an S-function:
*
* ssSetErrorStatus(S,"Error encountered due to ...");
* return;
*
* Note that the 2nd argument to ssSetErrorStatus must be persistent memory.
* It cannot be a local variable.
*/
static int
checkError(SimStruct *S){
if (ErrStat >= AbortErrLev){
ssPrintf("\n");
ssSetErrorStatus(S, ErrMsg);
mdlTerminate(S); // terminate on error (in case Simulink doesn't do so itself)
return 1;
}
else if (ErrStat >= ErrID_Warn){
ssPrintf("\n");
ssWarning(S, ErrMsg);
}
else if (ErrStat != ErrID_None){
ssPrintf("\n%s\n", ErrMsg);
}
return 0;
}
static void
getInputs(SimStruct *S, double *InputAry){
int k;
InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S, 0);
for (k = 0; k < ssGetDWorkWidth(S, WORKARY_INPUT); k++) {
InputAry[k] = (double)(*uPtrs[k]);
}
}
static void
setOutputs(SimStruct *S, double *OutputAry){
int k;
double *y = ssGetOutputPortRealSignal(S, 0);
for (k = 0; k < ssGetOutputPortWidth(S, WORKARY_OUTPUT); k++) {
y[k] = OutputAry[k];
}
}
/*====================*
* S-function methods *
*====================*/
/* Function: mdlInitializeSizes ===============================================
* Abstract:
* The sizes information is used by Simulink to determine the S-function
* block's characteristics (number of inputs, outputs, states, etc.).
*/
static void mdlInitializeSizes(SimStruct *S)
{
int i = 0;
int j = 0;
int k = 0;
static char ChannelNames[CHANNEL_LENGTH * MAXIMUM_OUTPUTS + 1];
static double InitInputAry[MAXInitINPUTS];
//static char OutList[MAXIMUM_OUTPUTS][CHANNEL_LENGTH + 1];
static char OutList[CHANNEL_LENGTH + 1];
double *AdditionalInitInputs;
mxArray *pm, *chrAry;
mwSize m, n;
mwIndex indx;
if (n_t_global == -2) {
/* Expected S-Function Input Parameter(s) */
ssSetNumSFcnParams(S, NUM_PARAM); /* Number of expected parameters */
if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
/* Return if number of expected != number of actual parameters */
return;
}
// The parameters should not be changed during the course of a simulation
ssSetSFcnParamTunable(S, PARAM_FILENAME, SS_PRM_NOT_TUNABLE);
mxGetString(ssGetSFcnParam(S, PARAM_FILENAME), InputFileName, INTERFACE_STRING_LENGTH);
ssSetSFcnParamTunable(S, PARAM_TMAX, SS_PRM_NOT_TUNABLE);
TMax = mxGetScalar(ssGetSFcnParam(S, PARAM_TMAX));
ssSetSFcnParamTunable(S, PARAM_ADDINPUTS, SS_PRM_NOT_TUNABLE);
NumAddInputs = (int)(mxGetScalar(ssGetSFcnParam(S, PARAM_ADDINPUTS)) + 0.5); // add 0.5 for rounding from double
if (NumAddInputs < 0){
ErrStat = ErrID_Fatal;
strcpy(ErrMsg, "Parameter specifying number of additional inputs to the FAST SFunc must not be negative.\n");
checkError(S);
return;
}
NumInputs = NumFixedInputs + NumAddInputs;
// now see if there are other inputs that need to be processed...
if (NumAddInputs > 0){
k = (int)mxGetNumberOfElements(ssGetSFcnParam(S, PARAM_ADDINPUTS));
k = min( k , MAXInitINPUTS );
AdditionalInitInputs = (double *)mxGetData(ssGetSFcnParam(S, PARAM_ADDINPUTS));
for (i = 0; i < k; i++){
InitInputAry[i] = AdditionalInitInputs[i + 1];
}
}
else{
InitInputAry[0] = SensorType_None; // tell it not to use lidar (shouldn't be necessary, but we'll cover our bases)
}
// set this before possibility of error in Fortran library:
ssSetOptions(S,
SS_OPTION_CALL_TERMINATE_ON_EXIT);
/* --------------------------------------------- */
// strcpy(InputFileName, "../../CertTest/Test01.fst");
FAST_Sizes(&TMax, InitInputAry, InputFileName, &AbortErrLev, &NumOutputs, &dt, &ErrStat, ErrMsg, ChannelNames);
n_t_global = -1;
if (checkError(S)) return;
// set DT in the Matlab workspace (necessary for Simulink block solver options)
pm = mxCreateDoubleScalar(dt);
ErrStat = mexPutVariable("base", "DT", pm);
mxDestroyArray(pm);
if (ErrStat != 0){
ErrStat = ErrID_Fatal;
strcpy(ErrMsg, "Error copying string array to 'DT' variable in the base Matlab workspace.");
checkError(S);
return;
}
// put the names of the output channels in a cell-array variable called "OutList" in the base matlab workspace
m = NumOutputs;
n = 1;
pm = mxCreateCellMatrix(m, n);
for (i = 0; i < NumOutputs; i++){
j = CHANNEL_LENGTH - 1;
while (ChannelNames[i*CHANNEL_LENGTH + j] == ' '){
j--;
}
strncpy(&OutList[0], &ChannelNames[i*CHANNEL_LENGTH], j+1);
OutList[j + 1] = '\0';
chrAry = mxCreateString(OutList);
indx = i;
mxSetCell(pm, indx, chrAry);
//mxDestroyArray(chrAry);
}
ErrStat = mexPutVariable("base", "OutList", pm);
mxDestroyArray(pm);
if (ErrStat != 0){
ErrStat = ErrID_Fatal;
strcpy(ErrMsg, "Error copying string array to 'OutList' variable in the base Matlab workspace.");
checkError(S);
return;
}
// ---------------------------------------------
ssSetNumContStates(S, 0); /* how many continuous states? */
ssSetNumDiscStates(S, 0); /* how many discrete states?*/
/* sets input port characteristics */
if (!ssSetNumInputPorts(S, 1)) return;
ssSetInputPortWidth(S, 0, NumInputs); // width of first input port
/*
* Set direct feedthrough flag (1=yes, 0=no).
* A port has direct feedthrough if the input is used in either
* the mdlOutputs or mdlGetTimeOfNextVarHit functions.
*/
ssSetInputPortDirectFeedThrough(S, 0, 0); // no direct feedthrough because we're just putting everything in one update routine (acting like a discrete system)
if (!ssSetNumOutputPorts(S, 1)) return;
ssSetOutputPortWidth(S, 0, NumOutputs);
ssSetNumSampleTimes(S, 1); // -> setting this > 0 calls mdlInitializeSampleTimes()
/*
* If your Fortran code uses REAL for the state, input, and/or output
* datatypes, use these DWorks as work areas to downcast continuous
* states from double to REAL before calling your code. You could
* also put the work vectors in hard-coded local (stack) variables.
*
* For fixed step code, keep a copy of the variables to be output
* in a DWork vector so the mdlOutputs() function can provide output
* data when needed. You can use as many DWork vectors as you like
* for both input and output (or hard-code local variables).
*/
if(!ssSetNumDWork( S, 2)) return;
ssSetDWorkWidth( S, WORKARY_OUTPUT, ssGetOutputPortWidth(S, 0));
ssSetDWorkDataType(S, WORKARY_OUTPUT, SS_DOUBLE); /* use SS_DOUBLE if needed */
ssSetDWorkWidth( S, WORKARY_INPUT, ssGetInputPortWidth(S, 0));
ssSetDWorkDataType(S, WORKARY_INPUT, SS_DOUBLE);
ssSetNumNonsampledZCs(S, 0);
/* Specify the sim state compliance to be same as a built-in block */
/* see sfun_simstate.c for example of other possible settings */
ssSetSimStateCompliance(S, USE_DEFAULT_SIM_STATE);
// ssSetOptions(S, 0); // bjj: what does this do? (not sure what 0 means: no options?) set option to call Terminate earlier...
}
}
/* Function: mdlInitializeSampleTimes =========================================
* Abstract:
* This function is used to specify the sample time(s) for your
* S-function. You must register the same number of sample times as
* specified in ssSetNumSampleTimes.
*/
static void mdlInitializeSampleTimes(SimStruct *S)
{
/*
* If the Fortran code implicitly steps time
* at a fixed rate and you don't want to change
* the code, you need to use a discrete (fixed
* step) sample time, 1 second is chosen below.
*/
ssSetSampleTime(S, 0, dt); /* Choose the sample time here if discrete */
ssSetOffsetTime(S, 0, 0.0);
ssSetModelReferenceSampleTimeDefaultInheritance(S);
}
#undef MDL_INITIALIZE_CONDITIONS /* Change to #undef to remove function */
#define MDL_START /* Change to #undef to remove function */
#if defined(MDL_START)
/* Function: mdlStart =======================================================
* Abstract:
* This function is called once at start of model execution. If you
* have states that should be initialized once, this is the place
* to do it.
*/
static void mdlStart(SimStruct *S)
{
/* bjj: this is really the initial output; I'd really like to have the inputs from Simulink here.... maybe if we put it in mdlOutputs?
but then do we need to say we have direct feed-through?
*/
double *InputAry = (double *)ssGetDWork(S, WORKARY_INPUT); //malloc(NumInputs*sizeof(double));
double *OutputAry = (double *)ssGetDWork(S, WORKARY_OUTPUT);
//n_t_global is -1 here; maybe use this fact in mdlOutputs
if (n_t_global == -1){ // first time to compute outputs:
// getInputs(S, InputAry);
FAST_Start(&NumInputs, &NumOutputs, InputAry, OutputAry, &ErrStat, ErrMsg);
n_t_global = 0;
if (checkError(S)) return;
}
}
#endif /* MDL_START */
/* Function: mdlOutputs =======================================================
* Abstract:
* In this function, you compute the outputs of your S-function
* block. The default datatype for signals in Simulink is double,
* but you can use other intrinsic C datatypes or even custom
* datatypes if you wish. See Simulink document "Writing S-functions"
* for details on datatype topics.
*/
static void mdlOutputs(SimStruct *S, int_T tid)
{
/*
* For Fixed Step Code
* -------------------
* If the Fortran code implements discrete states (implicitly or
* registered with Simulink, it doesn't matter), call the code
* from mdlUpdates() and save the output values in a DWork vector.
* The variable step solver may call mdlOutputs() several
* times in between calls to mdlUpdate, and you must extract the
* values from the DWork vector and copy them to the block output
* variables.
*
* Be sure that the ssSetDWorkDataType(S,0) declaration in
* mdlInitializeSizes() uses SS_DOUBLE for the datatype when
* this code is active.
*/
double *InputAry = (double *)ssGetDWork(S, WORKARY_INPUT);
double *OutputAry = (double *)ssGetDWork(S, WORKARY_OUTPUT);
if (n_t_global == -1){ // first time to compute outputs:
getInputs(S, InputAry);
FAST_Start(&NumInputs, &NumOutputs, InputAry, OutputAry, &ErrStat, ErrMsg);
n_t_global = 0;
if (checkError(S)) return;
}
setOutputs(S, OutputAry);
}
#define MDL_UPDATE /* Change to #undef to remove function */
#if defined(MDL_UPDATE)
/* Function: mdlUpdate ======================================================
* Abstract:
* This function is called once for every major integration time step.
* Discrete states are typically updated here, but this function is useful
* for performing any tasks that should only take place once per
* integration step.
*/
static void mdlUpdate(SimStruct *S, int_T tid)
{
/*
* For Fixed Step Code Only
* ------------------------
* If your Fortran code runs at a fixed time step that advances
* each time you call it, it is best to call it here instead of
* in mdlOutputs(). The states in the Fortran code need not be
* continuous if you call your code from here.
*/
double *InputAry = (double *)ssGetDWork(S, WORKARY_INPUT);
double *OutputAry = (double *)ssGetDWork(S, WORKARY_OUTPUT);
//time_T t = ssGetSampleTime(S, 0);
getInputs(S, InputAry);
/* ==== Call the Fortran routine (args are pass-by-reference) */
FAST_Update(&NumInputs, &NumOutputs, InputAry, OutputAry, &ErrStat, ErrMsg);
n_t_global = n_t_global + 1;
if (checkError(S)) return;
setOutputs(S, OutputAry);
}
#endif /* MDL_UPDATE */
#undef MDL_DERIVATIVES /* Change to #undef to remove function */
/* Function: mdlTerminate =====================================================
* Abstract:
* In this function, you should perform any actions that are necessary
* at the termination of a simulation. For example, if memory was
* allocated in mdlStart, this is the place to free it.
*/
static void mdlTerminate(SimStruct *S)
{
if (n_t_global > -2){ // just in case we've never initialized, check this time step
FAST_End();
n_t_global = -2;
}
}
/*=============================*
* Required S-function trailer *
*=============================*/
#ifdef MATLAB_MEX_FILE /* Is this file being compiled as a MEX-file? */
#include "simulink.c" /* MEX-file interface mechanism */
#else
#include "cg_sfun.h" /* Code generation registration function */
#endif
（2）Error information ↓
LINK : fatal error LNK1104: 无法打开文件“FAST_SFunc.obj”
NMAKE : fatal error U1077: “"H:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX86\x86\link.EXE"”: 返回代码“0x450”
Stop.
The make command returned an error of 2
'An_error_occurred_during_the_call_to_make' 不是内部或外部命令，也不是可运行的程序
或批处理文件。
### Creating HTML report file CFDLMFAC_codegen_rpt.html
b:\matlab\rtw\internal\rtwtags\rtwtags: error opening 'G:\A2_Doctor\1 FASTv8\Simulink\Samples\CFDL_MFAC_weifen_real_time\CFDLMFAC_slrt_rtw\FAST_SFunc.c'jianshen lihttps://jp.mathworks.com/matlabcentral/profile/authors/8704196tag:jp.mathworks.com,2005:Question/7571692021-02-26T15:59:26Z2021-02-27T01:02:49ZI got a error about “mxCreateDoubleScalar”is not defined in process of simulink real time I got errors about
“mxCreateDoubleScalar”is not defined;
“mexPutVariable”is not defined；
< "mxSetCell_ is_ not_ supported_ in_ Simulink_ Coder ": undeclared identifier> when build model for simulink real-time.
how can I continue?
I just learned that Simulink real time doesn't seem to support these defination. Is there an alternative solution to solve this problem?
thank you!
jianshen lihttps://jp.mathworks.com/matlabcentral/profile/authors/8704196tag:jp.mathworks.com,2005:Question/7575692021-02-27T00:54:43Z2021-02-27T00:54:43Z回帰学習器で作成した予測モデルの再帰について以前回帰学習器でアンサンブル学習のバギング木を用いて、2つの予測モデルを作成しました。
trainedModel1：説明変数５つ[A,B,C,D,E(t)] 目的変数１つ[E(t+1)]
＊ t：現時刻
trainedModel2：説明変数５つ[A,B,C,D,E(t)] 目的変数１つ[F(t+1)]
trainedModel2の説明変数であるEの代わりにtrainedModel1を次のステップの入力として再帰させたいのですが、
そのようなコードもしくは方法はありますでしょうか？
拓生 香山https://jp.mathworks.com/matlabcentral/profile/authors/19353940tag:jp.mathworks.com,2005:Question/7575642021-02-27T00:37:44Z2021-02-27T00:49:48ZLinear programming code not showing the solutionI extracted the following code from an online pdf that solves basic feasible solution of linear programming problems.
function vert = feassol(A, b)
% Basic feasible solutions vert to the system of constraints
% Ax = b, x >= 0.
% They are stored in columns of the matrix vert.
[m, n] = size(A);
warning off
b = b(:);
vert = [];
if (n >= m)
t = nchoosek(1:n,m);
nv = nchoosek(n,m);
for i = 1:nv
y = zeros(n,1);
x = A(:,t(i,:))\b;
if all(x >= 0 & (x ~= inf & x ~= -inf))
y(t (i, :)) = x;
end
end
else
error('Nuber of equations is greater than th neumber of variables.')
end
if ~isempty(vert)
vert = delcols(vert);
else
vert = [];
end
end
To test the code, the author used the system
A = [1 1 1 0; 0 1 0 1];
b = [6; 3];
and obtain the results
vert = feassol(A, b)
vert =
0 0 3 6
0 3 3 0
6 3 0 0
3 0 0 3
But whenever I run the code, I get
>> vert = feassol(A,b)
vert =
[]
What am I not doing right with the code? Any help will be much appreciated. Thanks in advance!salam mahamahttps://jp.mathworks.com/matlabcentral/profile/authors/4478798tag:jp.mathworks.com,2005:Question/3705282017-12-01T23:32:22Z2021-02-27T00:38:38ZControlling the color of crosshair raised by ginputHello, I need to use ginput. It "raises raises crosshair in the axes" - which is fine. Unfortunately, this crosshair is black, and in the axes where I need this function the background is, usually, black too, so the crosshair is very difficult to see. Changing background is not really an option. Until now I used an old version of Matlab, where this crosshair was drawn in XOR mode, and therefore this problem did not appear. Now i am forced to upgrade to the most current version, and now the XOR is banished by Mathworks. This creates problems in the described use case, but also in other use cases. Any ideas will be greatly appreciated.
Thank you,
Naum DerzhiNaum Derzhihttps://jp.mathworks.com/matlabcentral/profile/authors/1376471tag:jp.mathworks.com,2005:Question/7575592021-02-27T00:35:05Z2021-02-27T00:36:28Zx-axis difference between two graphs
Hi everyone,
I am trying to take the x-axis difference of two graphs with same y- values. Fitting curves to data points do not work up to 9th degree polynomial.
My data points( shown in red dots) should be matched with black solid curve y data points but that curve should be taken into account as a curve instead of data points because its data points are far less than mine.
Im trying to do difference by drawing lines and calculating the dx but each plot has around 20 data points and I have 60 more plots to go. It hurts at some point.
I appreciate any help. Thanks Hasan canarhttps://jp.mathworks.com/matlabcentral/profile/authors/21468083tag:jp.mathworks.com,2005:Question/7551942021-02-24T18:36:00Z2021-02-27T00:34:41ZIssue with presetting the data assigned to a variable in MATLAB App DesignerHello
I hope you are doing good. So I have defined some variables as shown in the figure. These variables are called in different functions in a MATLAB App Designer program.
Upon clicking a button, app.PIN is assigned as shown in the picture below, and the rest of the code is executed accordingly.(Start is given as 0 Stop is given as 30 Step is given as 1 by the user)
Now upon clicking a different button I am trying to assign a different value to app.PIN (Start as -30 Stop as 30 and Step of 1) and I am getting an error which says:
Unable to perform assignment because the size of the left side is 31-by-1 and the size of the right side is 1-by-61.
I think that makes sense and I feel that some of the variables must be preset before assigning a new value. I do not want to use different variables as app.PIN is used in a different function to plot the graphs. I am not interested in running the program all over again because some of the tables contain some data and i do not want to reset anything. Any help to reset/preset the current value of app.PIN would be greatly appreciated.
Thank you.SRIRAM NTIHIN GOPAL LANKAhttps://jp.mathworks.com/matlabcentral/profile/authors/16227755tag:jp.mathworks.com,2005:Question/7570092021-02-26T13:10:06Z2021-02-27T00:24:30ZDiscretising a size distribution function and area under the curve I have some parameters for some data and I am plotting a size distribution function. The probability function I am using is given below:
Currently I have the following code which plots the function:
clear
clc
close all
mu = 0.015; % geometric mean radius
sigma = 1.6; % geometric standard deviation
Ntot = 850; % total number concentration
nbins = 200; % number of bins
rMin = (mu/(10*sigma)); % determine the minimum radius
rMax = (mu*10*sigma); % determine the maximum radius
rs = logspace(log10(rMin),log10(rMax),nbins+1); % vector containing rs
for i = 1:length(rs)
sizedist = Ntot/((sqrt(2*pi))*log(sigma))*exp(-(log(rs./mu).^2)./(2*log(sigma^2)));
end
% plot the size distribution function
semilogx(rs,sizedist,'Linewidth',2);
xlim([10e-4 10e1]);
xlabel('Particle Radius, \mum');
ylabel('Number Concentration, cm^3');
The first problem I have occurs here. Shouldn't the area under the curve be equal to the total number concentration specified? As this doesn't seem to be the case.
For the model I am coding it is necessary for the aerosol population to be discretised into bins.
Now suppose I wish to discretise this function into bins, currently the vector rs is the bin edges. I would like to know how to find the number concentration in each bin, but as stated above the area under the curve doesn't seem to equal Ntot. Can anyone see whether i'm doing anything wrong?
What I would like to do is to determine the Number Concentration in each bin, which when added together should total the value of Ntot.
Hopefully someone can help!!! Liam Holbeche-Smithhttps://jp.mathworks.com/matlabcentral/profile/authors/17297908tag:jp.mathworks.com,2005:Question/7575542021-02-27T00:20:36Z2021-02-27T00:20:36ZRetrieve IMU data from a USB sensorHello,
I don't have expertise with Arduino so I was thinking in buying an BNO055 USB stick to acquire IMU data. Anyone can tell me if Matlab will recognize it? Do I need to convert the USB stick to a serial Port ?
Thanks in advance :-)Bicalhohttps://jp.mathworks.com/matlabcentral/profile/authors/18324811tag:jp.mathworks.com,2005:Question/7557192021-02-25T09:27:56Z2021-02-27T00:12:31ZHow can I improve segmentation of these images?I'm trying to segment ants in several thousand images (I've attached two images here). I'm then applying a colour detection function, with the ultimate aim of detecting paint marks on the abdomen of ants.
I've had some success with the below segmentation, but it also sometimes picks up the brood (the pale oval-shaped things in the image), as well as some of the border. I can't just use something like imclearborder, because often there are ants connected to these border pixels, right on the edge of the image.
I have also tried
K means clustering - but often the colour blobs are treated seperately to the ant body
imfindcircles (to try and isolate just the abdomen of ants) - not much success so far
I'm just wondering if anyone has any input or other methods to improve the segmentation.
ant = imread("ant.jpg") % read original image, call it "ant"
burnedAnt = createAntSegmentation(ant) % apply local function to ant image
%% display images side by side, check segmentation not too strict
fig = figure();
ax(1) = axes('Units','normalized','Position', [ .1 .1 .4 .8]);
ax(2) = axes('Units','normalized','Position', [ .5 .1 .4 .8]);
imshow(ant,'Parent', ax(1)) % display original image
imshow(burnedAnt, 'Parent', ax(2)) % display new burned image
linkaxes(ax)
%% create function to segment ants, and burn the mask onto the original
% image
function burnedAnt = createAntSegmentation(ant)
greyant = rgb2gray(ant); % convert image to grayscale
% threshold image. Higher = more lenient filering
adaptedAnt = adaptthresh(greyant, 0.38,"ForegroundPolarity","dark");
BW = imbinarize(greyant,adaptedAnt); % binarize ant image, using the above thresholding
BWopen = bwareaopen(~BW,800); % exclude pixels smaller than X
se = strel("disk",32); % create shape used for dilating image
% dilate image, expand the white pixels to ensure not cutting off relevant areas
BWdilate = imdilate(BWopen,se);
BWfilled = imfill(BWdilate,"holes"); % fill in any holes
%produce final image, mask burned onto original image, with black (k) fill.
burnedAnt = imoverlay(ant,~BWfilled,"k");
endBChttps://jp.mathworks.com/matlabcentral/profile/authors/17076341tag:jp.mathworks.com,2005:Question/7433222021-02-12T07:13:06Z2021-02-27T00:08:45ZHow to calculate the automatically some distance in the image based on the colour ? Hello all, I am interested to calculate the automatically some distance in the image based on the colour. Is it possible to calculate the distance ? For example i want to calculate the Ha1 , Ha2 , Ha3 and Ha4 in the sample a , Hb1 , Hb2 , Hb3 and Hb4 in the sample b, Hc1 , Hc2 , Hc3 and Hc4 in the sample c, Hd1 , Hd2 , Hd3 and Hd4 in the sample d, He1 , He2 , He3 and He4 in the sample e
please find the general image and image to calculate the distance. I am not expert at MATLAB, but i am interested to learn this code. I will appreciate if any one tell me an code to perform this operation.
Thanks a tonKristen Chappelhttps://jp.mathworks.com/matlabcentral/profile/authors/21509178tag:jp.mathworks.com,2005:Question/7557942021-02-25T10:42:59Z2021-02-27T00:05:33Zis their any way to calculate automatically this parameter from the image ?Hi all,
I am looking for the calculate the the parameter mentioned in the image, Is that possible to calculate from the image ?
(I have attached the original image and other one attached to understand you that which value i need to calculate, (Black width, highlighted with the lime colour))Thank you.Anish Khanhttps://jp.mathworks.com/matlabcentral/profile/authors/21629885tag:jp.mathworks.com,2005:Question/7515992021-02-21T06:23:21Z2021-02-27T00:02:52ZError using movmax indexI need to find the number of periods since a stock price recorded an 14-day high. My proposed method was to use the following andpossibly subtract the index from the current row:
n = 14
[M,I] = movmax(high,[n-1 0],'omitnan');
However, I return - "error using movmax. Too many output arguments."
Can someone please assist in my methodology.david crowleyhttps://jp.mathworks.com/matlabcentral/profile/authors/19260357tag:jp.mathworks.com,2005:Question/7568942021-02-26T10:43:13Z2021-02-27T00:01:27Zhow can i calculate z^2 distibution?Hi, I am currently trying to calculate z^2 distribution when z is folloing (0,a) gaussian distribution
how can i calculate z^2 distribution?jinseok shinhttps://jp.mathworks.com/matlabcentral/profile/authors/16009487tag:jp.mathworks.com,2005:Question/7574192021-02-26T21:12:35Z2021-02-26T23:51:01ZFind distance between one point and a subset of other points. I would like to find the distance between a point and all points in a matrix , where : a subset of . Mathematically, this would correspond to a vector with entries equal to the elements of the following set:
,
One way to do this is the following:
[~,Dist_i] = knnsearch(X(i,:),X, 'K', n);
Dist_iJ = Dist_i(J);
However, this requires nearest neighbor searches, so the above is not likely to scale well. Is there a fast, ideally built-in way to do this task? Samuel L. Polkhttps://jp.mathworks.com/matlabcentral/profile/authors/10862361tag:jp.mathworks.com,2005:Question/7575442021-02-26T23:40:23Z2021-02-26T23:40:23ZCheck if nullspace is contained in another + finding intersection of 2 nullspaces.1) How to check (return true) if the nullspace of A is contained in the nullspace of B?
2) How to find the intersection of nullspaces of A and B?
Thanks!Aayush Mathurhttps://jp.mathworks.com/matlabcentral/profile/authors/21656454tag:jp.mathworks.com,2005:Question/7574792021-02-26T21:51:09Z2021-02-26T23:39:04ZHow can I get randperm to return a permutation of a vector that has no entries at their original positions?I want take a random permutation of a vector such that all entries of the vector move to a new location.
For example, if I have a vector [1,2,3,4,5], then the following permutations are acceptable:
[2,1,4,5,3], [3,1,5,2,4], [5,4,2,3,1], etc.
However, for me, the following vector is not acceptable:
[2,4,3,5,1]
because the "3" has remained in the same location.
The "randperm" function in MATLAB allows for some of the entries in the vector to stay in the same position. Is there some way to use randperm that stops it from doing this? Or is there some other function out there that I am missing? (I have also looked at the functions "datasample" and "randsample" but they also do not seem to allow for this).Darcy Cordellhttps://jp.mathworks.com/matlabcentral/profile/authors/6864376tag:jp.mathworks.com,2005:Question/7575392021-02-26T23:24:23Z2021-02-26T23:24:23ZRun a script in each subfolders and extract results for each subfolders in another folder I have a 'folder' which contains several subfolders for each sea wave height and period :
-subfolder(1:n) : 'Hs(0.25:0.5:5.25) Tp(2.5:1:9.5)'
example: subfolder(1) : 'Hs(0:25) Tp(2.5)'
.....
subfolder(4) : 'Hs(0.75) Tp(2.5)'
.....
subfolder(7): 'Hs(1.25) Tp(3.5)'
subfolder(8) : 'Hs(1.25) Tp(4.5)'
....
subfolder(11) : 'Hs(1.25) Tp(9.5)'
....
subfolder(end): 'Hs(5.25) Tp(9.5)'
I have several subfolders which are the combination between different Hs and different Tp. In each subfolder there is a 'file.mat'. I have to run the same matlab code in each subfolder to extract results from 'file.mat' and save them in another folder.
I would like to get in each subfolder through a code which can distinguish the several Hs and Tp cases (double for cycle) and run a code in order to extract results from 'file.mat' and extrapolate data in another folder.
Please help, I am a beginner. EMILIO BASTAhttps://jp.mathworks.com/matlabcentral/profile/authors/15107978tag:jp.mathworks.com,2005:Question/7575292021-02-26T23:09:35Z2021-02-26T23:17:33Zsum of elements of an arrayI'm sorry for the stupid question, but If i have an array A = [1,2,5,7,9] and i want an array B = [1,3,8,15,24], progressive sum of the elemts in A, what is the code that returns me B? Thanks!RAFFAELE CANTERIhttps://jp.mathworks.com/matlabcentral/profile/authors/11192416tag:jp.mathworks.com,2005:Question/7575342021-02-26T23:15:34Z2021-02-26T23:16:45ZCalling Python 3rd party packages from MatlabIs it possible to use 3rd party python packages/subpackages from within Matlab? (as opposed to 3rd party modules)
I have a package ("mypackage") for python2.7. I installed it in a conda environment (using conda 4.9.2) and have verified I can run its modules from a Python console. The package has two subpackages: "modelA" and "modelB". Each subpackage holds a module named "run" that holds various commands for the relevant model.
I would like to be able call the two different "run" modules from within a Matlab script (Matlab 2020b). The ideal would be something like:
py.mypackage.modelA.run.foo(inputs)
and
py.mypackage.modelB.run.bar(different_inputs)
I've added "mypackage" to both the Python and Matlab search paths, and have tried moving the working directory to the folder holding "mypackage", but I always get the error: "Unable to resolve the name py.mypackage.modelA.run.foo".
I have been able to run a module successfully by moving the working directory to "...\mypackage\modelA", and then calling
py.run.foo(inputs)
However, if I then try moving to "...mypackage\modelB" and calling
py.run.bar(different_inputs)
I get another "Unable to resolve the name" error. My best guess is that the Python search path is still pointing to the "run" module for modelA, as I am still able to call py.run.foo. If this is the case, is it possible to remove a module from the Python search path in order to toggle between modules?Jonathan Kinghttps://jp.mathworks.com/matlabcentral/profile/authors/7729614tag:jp.mathworks.com,2005:Question/7573892021-02-26T20:13:34Z2021-02-26T23:12:07ZHow to show the image slice from the below example?Hello, I want to show the image slice from the below example, where CT and SPECT both are image array with the same width, size and spacing.
% This is a part of the code
% Visualize the CT and SPECT together
for m = 1:199
CT_img = new_CT(:,:,m);
SPECT_img = SPECT(:,:,m);
final_img = imfuse(CT_img, SPECT_img);
% Visualize CT and SPECT together
imshow(final_img, [-800 1000]);
end
% Now, I want to see the overlapped slices one by one, so I want somethig like:
show_20th_slice = imshow(final_img(:,:,20)) %...>> but this says: "Index in position 3 exceeds array bounds (must not exceed 3)."
How can I do this?blueshttps://jp.mathworks.com/matlabcentral/profile/authors/12150346tag:jp.mathworks.com,2005:Question/7575242021-02-26T23:04:11Z2021-02-26T23:10:02ZDisplaying a group of vectors on separate lines I am trying to display a number of vectors in separate lines. How can you create a matrix with each its rows equal to one a group of 1*n vectors? Alternately, can you use the display function to do this? I have tried using for example the command disp([a b]) but this displays the vectors all on a single line.
a = [1 2 3]; b = [4 5 6]; c = [4 5 6];
disp([a b c])
Aleem Andrewhttps://jp.mathworks.com/matlabcentral/profile/authors/13655223tag:jp.mathworks.com,2005:Question/7575192021-02-26T23:01:09Z2021-02-26T23:01:09ZHow to plot a graph that I already have in on paper My quesetion is that, how can I plot a graph that I already have it on a paper. It was given to me by my proffessor but I do not have its function. I attached a picture of it
x axis should be from 0 to 2021 (every 50 years)
y axis has no specific break down, just a limit somewhere on Y axis
I know how to label and put title but I need to know what function should I give to MATLAB to get that shape (I tried logarithm and square root but it I could not get the exact shape.
I appreciate every body's help in advanceAli Mirhttps://jp.mathworks.com/matlabcentral/profile/authors/21656886tag:jp.mathworks.com,2005:Question/7575142021-02-26T22:57:35Z2021-02-26T22:57:35ZChanging axes linewidth on a stacked plotI cannot change the axes linewidth on a stacked plot, at least in the way that I am able to change the axes linewidth in other types of plots. For example, I have tried the following with no change to the axes linewidth:
figure(1)
stackedplot(time_axis, detuneandpower)
hAx=gca;
hAx.LineWidth=2;Eugene Tsaohttps://jp.mathworks.com/matlabcentral/profile/authors/13548150tag:jp.mathworks.com,2005:Question/7571492021-02-26T15:18:34Z2021-02-26T22:55:57ZMatlab Zeros, What type of matrix will I get from this?Hello, I am trying to understand a code that I using in my project, could someone tell me what do I get from this operation?
scan_trous_carres0=zeros((size_lambda*size_period*size_etching_depth*size_phi),9)
The 9 comes from a column of a text file that where I am getting data, I am trying to figure out why I am I multiplying the values inside the parenthesis and then I have the 9 outisde that parenthesis. What kind of matrix will I get?Jose Cuevashttps://jp.mathworks.com/matlabcentral/profile/authors/18189427tag:jp.mathworks.com,2005:Question/4473792019-02-27T20:30:48Z2021-02-26T22:55:31ZCalculating Angular Velocity from Rigid Body data (Roll Pitch Yaw)?How do I calculate the angular velocity of a person's head turning at different angles. I obtained my data using qualalysis motion cature. I have the rigid body data (roll, pitch, yaw), and was wondering if anyone could help with code to get angular velocity from these? Thank you very much Matthew Murphyhttps://jp.mathworks.com/matlabcentral/profile/authors/9294109tag:jp.mathworks.com,2005:Question/7573692021-02-26T19:25:29Z2021-02-26T22:52:05ZCombine and average several *.mat filesHello
I have a problem and I need your help, please.
I have several *.mat files and each file has the same variables but with different values. I would like to find the average value of each variable (which is basically a row of numbers) and then create a new mat file to plot the averaged results.
I have been looking over the internet but I didn't find the correct way to do it.
Thank you for your help!
M.HMichael Henryhttps://jp.mathworks.com/matlabcentral/profile/authors/3236667tag:jp.mathworks.com,2005:Question/7574592021-02-26T21:41:53Z2021-02-26T22:52:05ZSolve system of equations with the symbolic matrixI have a 4x4 matrix T, and I know its last row to be [0 0 0 1]. I also know these equations:
After solving these by hand, I find that third column has no solution (except for [4,3], which i know to be 0).
My question is how can I keep these unsolved variables symbolic while solving the system?
I tried the following code:
T = sym('x', [4 4]);
T(4,:) = [0 0 0 1];
T
p_new1 = [2 0 0 1].';
p_old1 = [0 0 0 1].';
p_new2 = [3 0 0 1].';
p_old2 = [1 0 0 1].';
p_new3 = [2 0 1 1].';
p_old3 = [0 1 0 1].';
eqn1 = p_new1 == T*p_old1;
eqn2 = p_new2 == T*p_old2;
eqn3 = p_new3 == T*p_old3;
sol = solve([eqn1, eqn2, eqn3])
This results in a strut with 9 elements that are solved. It completely excludes third column which i want to remain symbolic like x13 x23 x33. How can I do this?Cengizhan Demirbashttps://jp.mathworks.com/matlabcentral/profile/authors/16872536tag:jp.mathworks.com,2005:Question/7574092021-02-26T20:57:26Z2021-02-26T22:40:57ZNot Sure How to Call a Norm from Within a FunctionHello,
I'm not sure how to make a plot of a norm that I found inside a function.
Here is my code, which will best help me explain:
clc; clear all;
ti = 0;
tf = 15;
global I11 I22 I33 Mx My Mz w10 w20 w30 eps10 eps20 eps30 eps40 IC K0
I11 = 160;
I22 = 400;
I33 = 400;
Mx = 0;
My = 0;
Mz = 45;
w10 = 2;
w20 = -1;
w30 = 1;
eps10 = 0;
eps20 = 0;
eps30 = 0;
eps40 = 1;
K0 = eps10^2+eps20^2+eps30^2+eps40^2;
IC = [w10 w20 w30 eps10 eps20 eps30 eps40];
[t, y] = ode45(@(t,y) DynEqn1(t,y,I11,I22,I33,Mx,My,Mz), [ti tf], IC);
figure (1)
plot(t,y(:,1:3))
figure (2)
plot(t,y(:,4:7))
figure (3)
plot(t,(norm(y(:,4:7))-K0))
function soln = DynEqn1(t,y,I11,I22,I33,Mx,My,Mz)
w1 = y(1);
w2 = y(2);
w3 = y(3);
eps1 = y(4);
eps2 = y(5);
eps3 = y(6);
eps4 = y(7);
disp(norm(y(4:7)))
w1_dot = (Mx - w2*w3*(I33-I22))/I11;
w2_dot = (My - w1*w3*(I11-I33))/I22;
w3_dot = (Mz - w1*w2*(I22-I11))/I33;
eps1_dot = .5*(w1*eps4-w2*eps3+w3*eps2);
eps2_dot = .5*(w1*eps3+w2*eps4-w3*eps1);
eps3_dot = .5*(-w1*eps2+w2*eps1+w3*eps4);
eps4_dot = -.5*(w1*eps1+w2*eps2+w3*eps3);
soln = [w1_dot; w2_dot; w3_dot; eps1_dot; eps2_dot; eps3_dot; eps4_dot];
end
Basically, if I just display the norm from within the function, I get the values. But I would like to plot those values (minus a set value) versus time, but can't get it to work.
I tried defining the norm from within the function as a variable, K, but that didn't work either.
Any help is appreciated.
Thanks,
JonJon Stapchuckhttps://jp.mathworks.com/matlabcentral/profile/authors/19994875tag:jp.mathworks.com,2005:Question/7573292021-02-26T18:39:22Z2021-02-26T22:35:46Zdoubleの行列を各セルに内包しているcell型変数の分解方法お世話になります。
下記のコードにおいて、t_req1~3の各セルに内包されている1✕45の全行列をy軸、altitudeをx軸としたグラフを作ることを最終的な目標としているのですが、
t_req1~3の各セルをそれぞれ個別に取得する事ができずエラーが出て困っています。
どなたか良い解決方法をご存じないでしょうか？
needed_velocity_tというエクセルファイルを送付します。
計算の過程で、このエクセルファイルからの読み込みが必要です。
検証の際はご利用ください。
clear
close all
A=1;
vini=1530;
syms r
assume(r > 0);
row=3000;
m=(4/3)*pi*(r^3)*row;
ips=8.854*10^-12;
e=1.602*10^-19;
k=1.38*10^-23;
fai=[-100,-10,5,10,18];
Vg=5000;
d=0.08;
E=Vg/d ;
R=sqrt(A/pi);
D=2*R;
%i=1:1000:50000;
%0~50kmまでの必要高度
filename = 'needed_velocity_t.xlsx';%軌道の維持に必要な速度即ち第一宇宙速度
sheet = 1;
xlRange = 'C2:C52';
subsetA = xlsread(filename,sheet,xlRange);
nv1=subsetA;%必要速度[m/s]
%50~100kmまでの必要高度
filename = 'needed_velocity_t.xlsx';
sheet = 1;
xlRange = 'C52:C102';
subsetB = xlsread(filename,sheet,xlRange);
nv2=subsetB;%必要速度[m/s]
%200~250kmまでの必要高度
filename = 'needed_velocity_t.xlsx';
sheet = 1;
xlRange = 'C202:C252';
subsetC = xlsread(filename,sheet,xlRange);
nv3=subsetC;%必要速度[m/s]
%0-50kmまでの高度取得
filename = 'needed_velocity_t.xlsx';
sheet = 1;
xlRange = 'B2:B52';
subsetD = xlsread(filename,sheet,xlRange);
H1=subsetD;%高度[m]
%50-100kmまでの高度取得
filename = 'needed_velocity_t.xlsx';
sheet = 1;
xlRange = 'B52:B102';
subsetE = xlsread(filename,sheet,xlRange);
H2=subsetE;%高度[m]
%200-250kmまでの高度取得
filename = 'needed_velocity_t.xlsx';
sheet = 1;
xlRange = 'B202:B252';
subsetF = xlsread(filename,sheet,xlRange);
H3=subsetF;%高度[m]
nd1=0.0039;
for i=1:51; %計算中では単位はm/s
around1(i)=(((i-1)*1000)+(10921*10^3))*pi; %任意高度における一周の距離
end
t_around1= around1/vini;%初速のままの時一周にかかる時間
tin1=t_around1;
Vin=A*vini*tin1; %取り込み口が通る体積
nin1=Vin.'*nd1; %取り込み時間中に取り込む粒子数
C=4*pi*ips*r; %キャパシタンス\
q=fai*C; %粒子の電荷量
%ここから排気速度の話
FE=E*q; %電場から受ける力
%必要な周回数の算出
int_q=int(q,[0.3*10^-3 4.96*10^-3],'IgnoreAnalyticConstraints', true)
d_q=double(int_q);
dq=d_q;
dltv=sqrt((2*abs(dq)*E*d)/m)-vini;
% bunbo=nv1.^2
% m_n=(bunshi.')/bunbo
% m_n_trans=m_n(:,1)
mdot1_n=nv1*A*nd1;
%int_mdot1=int(mdot1,[0.3*10^-3 4.96*10^-3],'IgnoreAnalyticConstraints', true)
%d_mdot1=double(int_mdot1)
nin_n=mdot1_n/m;
%nin_n=nin_n(:,1)
Vin_n=nin_n/nd1; %取り込み時間中に取り込む粒子数
tin1_n=Vin_n/(A*vini); %取り込み口が通る体積
t_around1_n=tin1_n;
around1_n=t_around1_n*vini;%
int_around1_n=int(around1_n,[0.3*10^-3 4.96*10^-3],'IgnoreAnalyticConstraints', true)
d_around1_n=double(int_around1_n);
% gom=pinv(around1_n)
nc1=(d_around1_n.')./around1;
%nd2の部
nd2=0.0036;
for i=1:51;
around2(i)=(((i+49)*1000)+(10921*10^3))*pi; %任意高度における一周の距離
end
t_around2= around2/vini;
tin2=t_around2;
Vin=A*vini*tin2; %取り込み口が通る体積
nin2=Vin.'*nd2; %取り込み時間中に取り込む粒子数
% C=4*pi*ips*r %キャパシタンス\
% q=fai*C %粒子の電荷量
% %ここから排気速度の話
% FE=E*q %電場から受ける力
%必要な周回数の算出nd2
dltv=sqrt((2*abs(dq)*E*d)/m)-vini;
% bunbo=nv2.^2
% m_n=(bunshi.')/bunbo
% m_n_trans=m_n(:,1)
mdot2_n=nv2*A*nd2;
%int_mdot1=int(mdot1,[0.3*10^-3 4.96*10^-3],'IgnoreAnalyticConstraints', true)
%d_mdot1=double(int_mdot1)
nin2_n=mdot2_n/m;
%nin_n=nin_n(:,1)
Vin2_n=nin2_n/nd2; %取り込み時間中に取り込む粒子数
tin2_n=Vin2_n/(A*vini); %取り込み口が通る体積
t_around2_n=tin2_n;
around2_n=t_around2_n*vini;%
int_around2_n=int(around2_n,[0.3*10^-3 4.96*10^-3],'IgnoreAnalyticConstraints', true)
d_around2_n=double(int_around2_n);
% gom=pinv(around1_n)
nc2=(d_around2_n.')./around2;
%nd3の部
nd3=0.0018;
for i=1:51;
around3(i)=(((i+199)*1000)+(10921*10^3))*pi; %任意高度における一周の距離
end
t_around3= around3/vini;
tin3=t_around3;
Vin3_n=A*vini*tin3; %取り込み口が通る体積
nin3_n=Vin.'*nd3; %取り込み時間中に取り込む粒子数
% C=4*pi*ips*r %キャパシタンス\
% q=fai*C %粒子の電荷量
% %ここから排気速度の話
% FE=E*q %電場から受ける力
%必要な周回数の算出nd3
dltv=sqrt((2*abs(dq)*E*d)/m)-vini;
% bunbo=nv2.^2
% m_n=(bunshi.')/bunbo
% m_n_trans=m_n(:,1)
mdot3_n=nv3*A*nd3;
%int_mdot1=int(mdot1,[0.3*10^-3 4.96*10^-3],'IgnoreAnalyticConstraints', true)
%d_mdot1=double(int_mdot1)
nin3_n=mdot3_n/m;
%nin_n=nin_n(:,1)
Vin3_n=nin3_n/nd3; %取り込み時間中に取り込む粒子数
tin3_n=Vin3_n/(A*vini); %取り込み口が通る体積
t_around3_n=tin3_n;
around3_n=t_around3_n*vini;%
int_around3_n=int(around3_n,[0.3*10^-3 4.96*10^-3],'IgnoreAnalyticConstraints', true)
d_around3_n=double(int_around3_n);
% gom=pinv(around1_n)
nc3=(d_around3_n.')./around3;
%必要周回数を得るのに必要な周回時間
Md=[1,2,3,10,12];%乾燥重量
Md1=Md(1,1);
Md2=Md(1,2);
Md3=Md(1,3);
Md4=Md(1,4);
Md5=Md(1,5);
%ΔVを満足するのに必要な粒子重量
DV=[20,40,80,120];%ΔV
DV1=DV(1,1);
DV2=DV(1,2);
DV3=DV(1,3);
DV4=DV(1,4);
ar=[0.3:0.6:1:5:10:45]*(10^-6);%新たに仮定した粒子半径
Vex=[125.04 74.882 51.356 15.736 9.4846 3.1883];
Vex1=Vex(1,1);
Vex2=Vex(1,2);
Vex3=Vex(1,3);
Vex4=Vex(1,4);
Vex5=Vex(1,5);
Vex6=Vex(1,6);
count=1;
for i=1:1:4;
for j=1:6;
for k=1:5;
W=Md(k)*(exp(DV(i)/Vex(j))-1);%ΔVを満足するのに必要な粒子重量
n=W./((4/3)*(ar.^3)*row);%ΔVを満足するのに必要な粒子の個数
%%
%各Mdと各粒子数密度の組み合わせにおける必要周回数
n_req1=n./nin1;%各Mdと各粒子数密度の組み合わせにおける必要周回数
n_req2=n./nin2;
n_req3=n./nin3_n;
%%
%必要周回数を満たすのに必要な航行時間
t_req1=t_around1*n_req1;%0~50km
t_req2=t_around2*n_req2;%50~100km
t_req3=t_around3*n_req3;%200~250km
NUM(count,1:11)={i,j,Vex(j),W,n,n_req1,n_req2,n_req3,t_req1,t_req2,t_req3};
count=count+1;
end
end
end
count2=count-1;
%ΔVを満足するのに必要な粒子の個数
n=NUM(1:count2,5);
%各Mdと各粒子数密度の組み合わせにおける必要周回数
n_req1=NUM(1:count2,6);
n_req2=NUM(1:count2,7);
n_req3=NUM(1:count2,8);
%必要周回数を満たすのに必要な航行時間
t_req1=NUM(1:count2,9);%0~50km
t_req2=NUM(1:count2,10);%50~100km
t_req3=NUM(1:count2,11);%200~250km
%%
%高度を行列にしたもの
count3=1;
for i=0:1:49;
altitude1=1+i;%0~50,50~100km
alt1(count3,1)={altitude1};
count3=count3+1;
end
count3.5=1;
for i=49:1:99;
altitude1=1+i;50~100km
alt1(count3,1)={altitude1};
count3.5=count3.5+1;
end
count4=count3+1;
for i=199:1:249;%200~250km
altitude2=1+i;
alt2(count4,1)={altitude2};
count4=count4+1;
end
altitude=cat(1,alt1,alt2);
count5=1;
for i=1:1:45;
a(i)=t_req1(1,i);
b(1,i)=cell2mat(a(i));%%%%%%%エラー発生個所%%%%%%%%%
%B(count5,45)=(b);
count5=count5+1;
end
現状で発生しているエラーは下記のとおりです
左辺のインデックスが右辺とサイズが適合しないため、代入は実行できません。
エラー: needed_cicle_vs_needed_velocity_ver6 (line 248)
b(1,i)=cell2mat(a(i));Noruji Mutohttps://jp.mathworks.com/matlabcentral/profile/authors/15655321tag:jp.mathworks.com,2005:Question/7541092021-02-23T17:58:57Z2021-02-26T22:30:09Zcovert data as matrixHi
need help .... to CONVERT data 5*15 ,that I get it from the following program ....as MATRIX contain row i=5 and column j =15
this is the program:
Q =(unifrnd(0,1,5,15))
save Q
if there is alot of number ... that is difficult to write matrix by using ; in every row.
WHAT I WRITE in the same program???? IF ANY PROF. KNOW...thanks alothasan shttps://jp.mathworks.com/matlabcentral/profile/authors/20648720tag:jp.mathworks.com,2005:Question/7575092021-02-26T22:23:54Z2021-02-26T22:23:54ZODE45 Related Question Hello, I am trying to replicate the attached figure. I am having trouble implenting ode45 in a way that covers a time span of 66 minutes for two equations. The equations are nearly identical except the second is a slighly reduced form of the first. The difference lies in essentially two terms within this function. The first is (P_B - v*t) and the second is (r*v/3). I need (P_B - v*t) to reduce to P_F from the interval 6 to 66 minutes and (r*v/3) to go to zero from the same interval. As you can see in the code I tried breaking these into two seperate parts, however when I combine the results I get slightly different results from the figure. I know the BGI @ 66 minutes from the figure is nearly 15 if not exactly 15. What can I do to combine these two equations such that they are evaluated from their respective intervals (the non-reduced form from 0 to 6 minutes and the reduced form from 6 to 66 minutes)?
clc; clear; close all;
alpha = 0.0125; %Ostwald N2 solubility
D = 2*10^-8; %Diffusion coefficient (cm^2/sec)
h = 3*10^-4; %Bubble thickness (dyne/cm)
H = 2.5*10^8; %Bulk modulus (dyne/cm^2)
P_B = 14.7*6.8947*10^4; %Initial ambient pressure (dyne/cm^2)
P_F = 4.3*6.8947*10^4; %Final ambient pressure (dyne/cm^2)
gamma = 30; %Surface tension (dyne/cm^2)
V_tiss = 1; %Tissue volume (cm^3)
M = H/V_tiss; %Modulus of elasticity (dyne/(cm^2*cm^3))
P_N2o = 11.6*6.8947*10^4; %N2 initial tension (dyne/cm^2)
P_met = 1.76*10^5; %Metabolic gas tension (dyne/cm^2)
r = 0.0003; %Nucleation radius (cm)
t_a = 6*60; %Ascent time
v = (P_B - P_F)/t_a; %Ascent rate
P_N2 = P_N2o-P_N2o*(1-exp(-.00192*120));
tspan = 0:.1:6;
f = P_B - v*tspan;
plot(tspan, f)
tspan = [0 6*60];
r0 = r;
[t,r] = ode45(@(t,r)((-alpha*D/h)*(P_B-v*t+ 2*(gamma/r) + (4/3)*pi*M*r^3 ...
-P_N2 - P_met) + r*v/3)/(P_B-v*t + (4/3)*gamma/r + (8/3)*pi*M*r^3), tspan, r0);
BGI = r/r0;
plot(t/60,BGI)
grid on
xlabel('Time After Ascent (min)')
ylabel('BGI')
ylim([0 16])
tspan = [6*60 66*60];
r0 = r(41);
[t,r] = ode45(@(t,r)((-alpha*D/h)*(P_F + 2*(gamma/r) + (4/3)*pi*M*r^3 ...
-P_N2 - P_met))/(P_F + (4/3)*gamma/r + (8/3)*pi*M*r^3), tspan, r0);
BGI = r/0.0003;
plot(t/60,BGI)
grid on
xlabel('Time After Ascent (min)')
ylabel('BGI')
ylim([0 16])
Ryan Griffithhttps://jp.mathworks.com/matlabcentral/profile/authors/16164871tag:jp.mathworks.com,2005:Question/7575042020-11-10T05:00:00Z2021-02-26T22:18:15ZError with 'geosoftread' while reading file'GETGEODATA' only returns NaNs for certain datasets (e.g. in reproduction steps). When it does so it also shows the following warning:
gplid = 'GPL21572';
url = sprintf('https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?form=text&acc=%s&view=full',gplid);
file = [tempdir '/' gplid '.txt'];
urlwrite(url, file);
gpldata = geosoftread( file );
Warning: Unable to read some lines of the file. Missing entries will be replaced with NaNs.
I also tried downloading the file and use 'getgeodata' but no luck.
Please, can I know if there is a workaround?MathWorks Support Teamhttps://jp.mathworks.com/matlabcentral/profile/authors/4622813tag:jp.mathworks.com,2005:Question/7541792021-02-23T19:20:38Z2021-02-26T22:16:09ZLogical with complex numbers in a vectorI have a complex number in a vector,
e =
-0.0000
3.0000
9.0000
>> logical(e) %checking if the the first entry is actually 0. Results show it is not
ans =
3×1 logical array
1
1
1
>> t = sqrt(e) % sqauring the entries shows all the three entries are complex numbers
t =
0.0000 + 0.0000i
1.7321 + 0.0000i
3.0000 + 0.0000i
L = logical(t) % In Matlab documentation it not possible to use logical for complex numbers
Error using logical
Complex values cannot be converted to logicals.
>> t(1,1)==0 % checking if the first entry is actually 0?
ans =
logical
0
>> t(1,1)<0 % checking if the first entry is actually less than 0?
ans =
logical
0
>> t(1,1)>0 % checking if the first entry is actually greater than 0?
ans =
logical
0
% QUESTION: is there a way to compare t(1,1) with 0 to know whether is it 0 or not?
% Alternatively: What is the genral way of using logicals for complex numbers?salam mahamahttps://jp.mathworks.com/matlabcentral/profile/authors/4478798tag:jp.mathworks.com,2005:Question/7574992021-02-16T05:00:00Z2021-02-26T22:11:31ZHow to sort figure handles in MATLAB?I have an array with multiple figure handles and would like to have them in a sorted order, by ascending figure number.
However when I call the sort function I do not always get the right order, and it changes between MATLAB sessions.
How can I get my figures sorted by their number?
Here is a reproduction example:
>> figs = [figure(1); figure(4); figure(2); figure(3)];
>> s_figs = sort(figs);
The result:
figs =
4×1 Figure array:
Figure (1)
Figure (4)
Figure (2)
Figure (3)
s_figs =
4×1 Figure array:
Figure (3)
Figure (2)
Figure (1)
Figure (4)
When I would like:
s_figs =
4×1 Figure array:
Figure (1)
Figure (2)
Figure (3)
Figure (4)MathWorks Support Teamhttps://jp.mathworks.com/matlabcentral/profile/authors/4622813tag:jp.mathworks.com,2005:Question/7574942021-02-26T05:00:00Z2021-02-26T22:08:49ZPermanent Magnet Synchronous Motor (PMSM) equation in MathWorks documentation doesn't match the equations elsewhere.PMSM equation according to the MathWorks document doesn't match the equation elsewhere. According to the books the evaluation for electromagnetic torque should be:
Te = 1.5*PM.p/2*(PM.Flux*u(1)+(PM.Ld-PM.Lq)*u(1)*u(2))
However, according to MathWorks document:
Te=1.5p[λiq+(Ld−Lq)idiq]
Why is the "/2" been omitted in the MathWorks equation for PMSM?
MathWorks Support Teamhttps://jp.mathworks.com/matlabcentral/profile/authors/4622813tag:jp.mathworks.com,2005:Question/7522292021-02-22T03:56:12Z2021-02-26T22:05:56ZMy code does not work for double helix on toroid
Hello,
I would appreciate if anyone could help me on this.
My code does not work for double helix on toroid: I want to control the radius of the smaller helix and the number of turns. I would appreciate any suggestions.
%HELIX ON HELIX_CYLINDRICAL
clear
clc
%
syms t r R h
assume(t,'real')
assume(R,'real')
assume(h,'real')
% CYLINDRICAL HELIX
x=h*t;
y=R*cos(t);
z=R*sin(t);
% % HELIX ON TORUS
% % VARIABLES
% R=3;% MAJOR RADIUS
% r=1;% MINOR RADIUS
% n=6;% No. of loops
% x = (R + r*cos(n*t)).*cos(t);
% y = r*sin(n*t);
% z = (R + r*cos(n*t)).*sin(t);
% r_vec is the equation of the curve of interest: here helix
r_vec=[x;y;z];
dx=diff(x);
dy=diff(y);
dz=diff(z);
tan_vec=[dx;dy;dz];
nor_vec=diff(tan_vec)/simplify(norm(diff(tan_vec)));
binor_vec=simplify((cross( tan_vec, nor_vec))/norm(tan_vec));
%parametrized for the next curve
syms a
assume(a,'real')
%Number of turns of the second helix
n2=12;
u=n2*t;
S= r_vec + a.*nor_vec.*cos(u)+a.*binor_vec.*sin(u);
% VARIABLES FOR THE SECOND LEVEL HELIX
% a= radius
h_num=1; R_num=3; a_num=0.5;
S1=subs(S, [h, R, a], [h_num, R_num, a_num]);
% %%Plotting
% R=6; r=2; n=5;
t1 = 0:pi/100:40*pi;
% u1 = 0:pi/15:2*pi;
% x1=R.*cos(t)+r.*cos(t).*cos(n.*t);
% y1=R*sin(t)+r*cos(n.*t).*sin(t);
% z1=r*sin(n.*t);
% x1=S1(1)
% y1=S1(2)
% z1=S1(3)
x2=double(subs(S1(1),t ,t1)); y2=double(subs(S1(2),t ,t1)); z2=double(subs(S1(3),t ,t1));
% x3=double(subs(x2,u ,u1)); y3=double(subs(y2,u ,u1)); z3=double(subs(z2,u ,u1));
%x2=subs(x1,[t, u], [t1, u1])
% %subs(x, t)
plot3(x2,y2,z2)
axis equal
xlabel('x(t)')
ylabel('y(t)')
zlabel('z(t)')
% HELIX ON TORUS DIRECT FORUMLA
%
t = 0:pi/500:40*pi;
% VARIABLES
R=3;% MAJOR RADIUS
r=1;% MINOR RADIUS
n=6;% No. of loops
xt = (R + r*cos(n*t)).*cos(t);
yt = r*sin(n*t);
zt = (R + r*cos(n*t)).*sin(t);
plot3(xt,yt,zt)
axis equal
xlabel('x(t)')
ylabel('y(t)')
zlabel('z(t)')
%
%HELIX ON HELIX_CYLINDRICAL
clear
clc
%
syms t r R h
assume(t,'real')
assume(R,'real')
assume(h,'real')
% CYLINDRICAL HELIX
% x=h*t;
% y=R*cos(t);
% z=R*sin(t);
% % HELIX ON TORUS
% % VARIABLES
R=3;% MAJOR RADIUS
r=1;% MINOR RADIUS
n=6;% No. of loops
x = (R + r*cos(n*t)).*cos(t);
y = r*sin(n*t);
z = (R + r*cos(n*t)).*sin(t);
% r_vec is the equation of the curve of interest: here helix
r_vec=[x;y;z];
dx=diff(x);
dy=diff(y);
dz=diff(z);
tan_vec=[dx;dy;dz];
nor_vec=diff(tan_vec)/simplify(norm(diff(tan_vec)));
binor_vec=simplify((cross( tan_vec, nor_vec))/norm(tan_vec));
%parametrized for the next curve
syms a
assume(a,'real')
%Number of turns of the second helix
n2=12;
u=n2*t;
S= r_vec + a.*nor_vec.*cos(u)+a.*binor_vec.*sin(u);
% VARIABLES FOR THE SECOND LEVEL HELIX
% a= radius
h_num=1; R_num=3; a_num=0.5;
S1=subs(S, [h, R, a], [h_num, R_num, a_num]);
% %%Plotting
% R=6; r=2; n=5;
t1 = 0:pi/100:40*pi;
% u1 = 0:pi/15:2*pi;
% x1=R.*cos(t)+r.*cos(t).*cos(n.*t);
% y1=R*sin(t)+r*cos(n.*t).*sin(t);
% z1=r*sin(n.*t);
% x1=S1(1)
% y1=S1(2)
% z1=S1(3)
x2=double(subs(S1(1),t ,t1)); y2=double(subs(S1(2),t ,t1)); z2=double(subs(S1(3),t ,t1));
% x3=double(subs(x2,u ,u1)); y3=double(subs(y2,u ,u1)); z3=double(subs(z2,u ,u1));
%x2=subs(x1,[t, u], [t1, u1])
% %subs(x, t)
plot3(x2,y2,z2)
axis equal
xlabel('x(t)')
ylabel('y(t)')
zlabel('z(t)')
%%
% HELIX ON TORUS DIRECT FORUMLA
%
t = 0:pi/500:40*pi;
% VARIABLES
R=3;% MAJOR RADIUS
r=1;% MINOR RADIUS
n=6;% No. of loops
xt = (R + r*cos(n*t)).*cos(t);
yt = r*sin(n*t);
zt = (R + r*cos(n*t)).*sin(t);
plot3(xt,yt,zt)
axis equal
xlabel('x(t)')
ylabel('y(t)')
zlabel('z(t)')SANGRAM ROUThttps://jp.mathworks.com/matlabcentral/profile/authors/16969265tag:jp.mathworks.com,2005:Question/7574392021-02-26T21:26:48Z2021-02-26T21:58:44ZLooping error where i want to get 5 instances of any same number in a columnSo i have a column of data which consists of numbers where i have to find 5 instances of the same number. So ,for example, 8,8,8,8,8,8,8,8,8,9,9,9,5,6,4,7,,6,2,3, etc. In this 8 has occurred 9 times. So i want to increment the count only once because even though there are nine 8's what my code is doing is taking the first 8 and getting the 5 consecutive numbers are incrementing. Then it takes the next 8 and increments the count and so on where the count becomes 5 but i want it to be 1. What i want is the first occurrence of any number to be the base value and take 5 consecutive numbers and increment the count. Then then take the 6th 8 and count if there are 5 consecutive 8's or that specific number or not. So, for example, 8,8,8,8,8,8,9,9,9,9,9,9,9,9,5,5,5,5,5,1,1,2,2,5,4,3,6,7,9,3,4,2,2,2,2,2,1,2,1. In this the count should be 4.
The code was :
count=0;
for i=1:length(data)-4
if data(i)==8 && sum(diff(data(i:i+4))==0)==4
count=count+1;
end
end
So in this code, it's only checking for 8 whereas i need it for all the numbers with 5 consecutive occurrences and it is checking for 5 consecutive but without skipping the first 5 taken into the consecutive count. I'm new to Matlab and this question is a bit tricky for me as i'm not good in logic building.
If(count_consecutive==5){
count_main=count_main+1; ...
a[i]=a[i+5];// continue for the base value. It should skip all the numbers that were counted in the consecutive count one and take the next number as the base for counting the consecutive numbers}
Thanks for any help. It would be greatly appreciated :).Karthik Garimellahttps://jp.mathworks.com/matlabcentral/profile/authors/19624616tag:jp.mathworks.com,2005:Question/7574892021-02-26T05:00:00Z2021-02-26T21:57:14ZCan an S-function created on a newer release of MATLAB work on an older release ?Can an S-function created on a newer release (say R2018b) work/be exported to an older version of MATLAB?MathWorks Support Teamhttps://jp.mathworks.com/matlabcentral/profile/authors/4622813tag:jp.mathworks.com,2005:Question/7573942021-02-26T20:20:44Z2021-02-26T21:56:33Zdetrending timeseries by removing the linear function fitted by samples?I am trying to detrend a timeseries based on one sample of the timeseries in matlab.
I basically want my sample points to be all the points between 11-22, but I am getting an error saying that the t variable has to be equal to the what tac is (which is 71).
I've tried this and this does not work:
tac = 71x1 double
t = 11:22;
d_tac_ts_2 = detrend(tac,‘SamplePoints’,t)
I get this error:
Error using detrend>checkSamplePoints (line 284)
The number of elements in the 'SamplePoints' value must equal the size of
the first argument along the first dimension.
Error in detrend>parseNV (line 266)
s = checkSamplePoints(varargin{j+1},x);
Error in detrend>parseInputs (line 161)
[continuity,s] = parseNV(1,nargin,continuity,s,x,varargin{:});
Error in detrend (line 50)
[x,polyDeg,bp,s,continuity,sizeX,N,isrowx,isNDx,lbp] = parseInputs(x,
varargin{:});
Error in plotting_ref_TAC_vs_TAC_PET (line 28)
d_tac_ts_2 = detrend(tac,'SamplePoints',t)
This works, but does not do what I want:
t = 1:71;
d_tac_ts_2 = detrend(tac,‘SamplePoints’,t)
thanks so much for any help!
nineshttps://jp.mathworks.com/matlabcentral/profile/authors/15883041tag:jp.mathworks.com,2005:Question/7574842021-02-26T05:00:00Z2021-02-26T21:54:25ZIs there a way to use FRD(Frequency Response Data) in Simulink model instead of an LTI SS block?While trying to simulate a control system , with FRD collected from actual hardware, is there a way to use this FRD data in their Simulink model instead of an LTI SS block?MathWorks Support Teamhttps://jp.mathworks.com/matlabcentral/profile/authors/4622813tag:jp.mathworks.com,2005:Question/7562242021-02-25T18:04:47Z2021-02-26T21:53:41ZHow to pick files from sub-folderI have two sub-folders with images and require to perform operations using them. When i am running the code with sub-folder in the current folder window its being executed but i need to extract them from the main folder and run them. Also the ouput is a text file, which needs to be present in respective sub-folders instead of the current folder window. Please help me with these issues. Thank you in advance. Aishwarya Sanakahttps://jp.mathworks.com/matlabcentral/profile/authors/21284128tag:jp.mathworks.com,2005:Question/7574742021-01-19T05:00:00Z2021-02-26T21:43:37ZHow can I perform convolution operations on time steps of image sequences independently?I would like to do something similar to training a neural network with an image sequence (i.e., video as input). With this, I need to perform convolutions independently for 5 different timesteps. To achieve this, I am using a "sequenceFoldingLayer" followed by a "sequenceUnfoldingLayer." However, these are both unsupported layers of "dlnetwork." How can I achieve this workflow?MathWorks Support Teamhttps://jp.mathworks.com/matlabcentral/profile/authors/4622813tag:jp.mathworks.com,2005:Question/7574692021-02-26T21:43:32Z2021-02-26T21:43:32ZThree variables (two independent) 3D plottingActually, in my code, I have obtained matrix of R (using one 'for' loop on either 'B' or 'L') not scalar value, and able to plot between B and R or L and R. But I want to plot B vs L vs R at the same time. Please guide me. More accurate example could be taken as
clear all
clc
R=[];
for B=-20:20;
M=1;
X=M+B;
T=[];
for L=-10:10;
N=2;
Y=N+X;
r=B+Y+L^2;
T=[T r];
end
R=[R T];
end
MOHD UWAIShttps://jp.mathworks.com/matlabcentral/profile/authors/15689444tag:jp.mathworks.com,2005:Question/7574642021-02-26T21:42:59Z2021-02-26T21:42:59ZHow can I extract a slice from a multidimensional array?I have an array of variable dimensions and want to extract a slice of it.
If I the size of the array was fixed I would like to do:
result = G(:,:,:,r,:,:);
But in my case, r is a variable and so are the dimensions of G and the dimension from which I want to extract the slice (in this case the 4th dimension).
-----------------------------------
I am able to costruct a cell array containing the indices that need to be extracted, but can't extract them.
N = ndims(G);
other_dimensions = [1:(n-1),(n+1):N];
sz = size(G);
inds = repmat({r},1,ndims(G));
for k = 1:length(other_dimensions)
inds{other_dimensions(k)} = 1:sz(other_dimensions(k));
end
result = A(inds) % (not working)
Uri Goldsztejnhttps://jp.mathworks.com/matlabcentral/profile/authors/10815133tag:jp.mathworks.com,2005:Question/7574542021-02-16T05:00:00Z2021-02-26T21:38:57ZWhy does the equation solver return only one root when using "abs"?I am using the Symbolic Math Toolbox.
When my equation has an absolute value the solver only returns one of the two roots.
Is this behavior expected?
Here is a reproduction example:
>> syms x
>> solve(abs(x) == 1) % ans = 1
>> solve(sqrt(x^2) == 1) % ans = [-1; 1]MathWorks Support Teamhttps://jp.mathworks.com/matlabcentral/profile/authors/4622813tag:jp.mathworks.com,2005:Question/7568792021-02-26T10:19:24Z2021-02-26T21:37:11ZHow can I link data from separate arrays? Suppose you have an array [4 7 9 4 8 3] which represents a list of parameter values within a database. For example ‘4’ is the thickness of a plate which has an associated array containing location and temperature values (5x2 double) [0.55 0.16; 0.60 0.16; 0.65 0.15; 0.7 0.14; 0.75 0.12]. Each of the thickness values has an associated 5x2 array which is unique.
So the question I have is this: Is there a way I can link the location and temperature data arrays with the thickness values so that I can plot all the arrays which correspond to thickness value of ‘4’ without doing this manually?Matthew Weltevredenhttps://jp.mathworks.com/matlabcentral/profile/authors/15137593tag:jp.mathworks.com,2005:Question/7574242021-02-26T21:22:39Z2021-02-26T21:34:08ZDisplaying an integer value in a numeric edit field in App DesignerI am trying to make an edit field display an integer value instead of using scientific notation. I would like to do it in a Value Changed Function after the code seen here:
% Value changed function: AmbientFieldEditField
function AmbientFieldEditFieldValueChanged(app, event)
value1 = app.AmbientFieldEditField.Value;
app.Ba_mag = value1;
I have tried a few things with no success such as:
int8(round(app.AmbientFieldEditField.Value,0));
I am not sure if I am even on the right track. I will also eventually need to apply the same change to the Z-axis of a 3D plot.
The edit field:
Any help is appreciated, thanks!Joshua Mitchellhttps://jp.mathworks.com/matlabcentral/profile/authors/21559475tag:jp.mathworks.com,2005:Question/7573392021-02-26T18:50:05Z2021-02-26T21:33:21Z3D or surface plotHi,
Please look at my problem. I have a 'A' as dependent variable of two variables B and L. How I could plot in 3D or surface plot of these three variables. If I have two 'for loop' like (for example),
for B=-10:10;
for L=-10:10;
A=B+L^2;
end
end
MOHD UWAIShttps://jp.mathworks.com/matlabcentral/profile/authors/15689444tag:jp.mathworks.com,2005:Question/7574492021-02-09T05:00:00Z2021-02-26T21:30:55ZWhy am I getting the error "No suitable match exists for file" in my unit test?I am running a suite of unit tests that previously worked, but now I am experiencing an error that reads "No suitable match exists for file". This only occurs for some of the unit tests that are accessing external files.
Error using matlab.unittest.internal.services.fileextension.MATLABCodeFileExtensionService/createSuiteExplicitly (line 29)
Invalid default value for property 'someProp' in class 'someTest':
No suitable match exists for file
Why am I experiencing this error?MathWorks Support Teamhttps://jp.mathworks.com/matlabcentral/profile/authors/4622813