https://fr.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2020-03-31T03:04:37Ztag:fr.mathworks.com,2005:Question/5124762020-03-23T18:48:49Z2020-03-31T03:04:37ZWhat is the meaning of L1 norm, L2 norm, Max norm in Wavelet?I want to know the exact and detailed meaning.
If you can see the meaning of L1 in the graph below?
Jungtae Kimhttps://fr.mathworks.com/matlabcentral/profile/authors/15780792-jungtae-kimtag:fr.mathworks.com,2005:Question/5139442020-03-30T12:37:40Z2020-03-31T03:03:14ZPlease help me to correct my for-loopHey all, I have a 1x3 cell with three 360x3 table. Each table has a column date with 30 years of the monthly data (30x12 = 360).
So I used this code below:
%get first array of the cell
table = CELL{1};
table.month = month(tbl.dates);
table.seasons = floor(tbl.month ./ 3);
table.seasons(tbl.seasons == 4) = 0;
table.seasons = categorical(tbl.seasons, [0 1 2 3], ["Spring", "Summmer", "Autumn", "Winter"]);
[group, mean_table] = findgroups(table(:, 'seasons'));
mean_table.rrr24 = splitapply(@sum, table.rrr24, group);
This code above calculates seasonal data just for the first array of the cell:
meanTbl =
4×2 table
season rrr24
______ ______
Spr 14.038
Sum 35.004
Aut 10.949
Win 16.958
Now I want to apply the above-mentioned code to all arrays of cell; then save the result in another cell (3 x 4, Three years and four seasons).
Here is my try I want to ask you if you please correct me:
for i = 1:numel(CELL)
table.month(i) = month(table(i).dates);
table(i).seasons = floor(table(i).month ./3);
table(i).seasons(table(i).seasons ==4) = 0;
table(i).seasons = categorical(table(i).seasons, [0 1 2 3], ["Spring", "Summer", "Autumn", "Winter"]);
[group, mean_table(i)] = findgroups(table(i)(:, 'seasons'));
mean_table(i).rrr24 = splitapply(@sum, table(i).rrr24, group);
for j = 1:3
newCELL{j,i} = mean_table(i); %newCELL is 3 x 4 cell array
end
end
Thank you so much.Behzad Navidihttps://fr.mathworks.com/matlabcentral/profile/authors/15525777-behzad-naviditag:fr.mathworks.com,2005:Question/4830792019-10-01T17:22:25Z2020-03-31T03:02:52ZHow to download multiple data files at once using matlabI need to call on a website and download data for each and every day for the month of july. Im curious what command or format can help me do this. For example this is the code to retrieve 1 day of the year.
filename='weather_data_2019_255.txt';
if isfile(filename)
fprintf('already have the file |%s|\n',filename);
else
url='http://www.weather.unh.edu/data/2019/255.txt';
outname=websave(filename,url);
fprintf('got weather data file |%s|\n',outname);
end
How can i change the filename to allow me to download filename='weather_data_2019_(182-212).txt. I'm assuming I need to create a start date and a end date and create an output filename. May someone teach me how I can do this. Thank you very much.
Edward McLellanhttps://fr.mathworks.com/matlabcentral/profile/authors/16033642-edward-mclellantag:fr.mathworks.com,2005:Question/5141512020-03-30T22:34:51Z2020-03-31T03:02:03ZFrom nested structure to table in one line of codeI have a structure S with n fields S_field_1, S_field_2,…S_field_n. Each field contains a structure with the same number m and name of fields field_1, field_2…field_m.
How do I get a nxm table with variables field_1, field_2…field_m with a single line of code?
Thank you!Giovanni Barbarossahttps://fr.mathworks.com/matlabcentral/profile/authors/8731259-giovanni-barbarossatag:fr.mathworks.com,2005:Question/4898642019-11-07T22:48:44Z2020-03-31T03:01:57Zhow to train deep learning network with multi-inputsHi I need to train a CNN with two different type of images, so I used the following code
inputSize = [64 64 64 4];
inputLayer = image3dInputLayer(inputSize,'Normalization','none','Name','input');
inputLayer2 = image3dInputLayer(inputSize,'Normalization','none','Name','input2');
when I used analyzeNetwork(lgraph), I got error that should only one input layer be used. So please is there any way I can use multi inputs in the matlab?
Also, if multi inputes is supported in matlab, how can define the two different inputs in the training process ( trainNetwork(dsTrain,lgraph,options);)
I appreciate your advice!
ThanksLina Chatohttps://fr.mathworks.com/matlabcentral/profile/authors/11418461-lina-chatotag:fr.mathworks.com,2005:Question/5141712020-03-31T01:50:36Z2020-03-31T03:00:57ZHello. I am trying to simulate prices for an American option. Below is my code. When you run the code, you will get values for S1, S2, S3, and S4. I want to print out the results in a matrix, because I need to use them later. I tried using multi normial tree, and toeplitz function but I wasn't able to get the results into a nice form. Any help/suggestions would be appreciated. Thank you
K=100; r=0.05; delta=0.1; T=1; sigma=0.2; n=100; b=2; dt=1/3;
S1=70*ones(1,1); % stock price at time t = 0
S2=zeros(b,1); % stock price at time t = 1/3
S3=zeros(b*b,1); % stock price at time t = 2/3
S4=zeros(b*b*b,1); % stock price at time t = 1
%generate S2 based on S1 by using equation (8).
%generate S3 based on S2 by using equation (8).
%generate S4 based on S3 by using equation (8).
t=[0;1/3;2/3;1];
S=[S1;S2;S3;S4];
o=length(S);
for i=1:b
z=normrnd(0,1);
S2(i)=S1*exp((r-delta-(sigma)^2)*(dt)+sigma*sqrt(dt)*z)
end
for i=1:b
for j=1:b
z=normrnd(0,1);
S3((i-1)*b+j)=S2(i)*exp((r-delta-(sigma)^2)*(dt)+sigma*sqrt(dt)*z)
end
end
for i=1:b*b
for j=1:b
z=normrnd(0,1);
S4((i-1)*b+j)=S3(i)*exp((r-delta-(sigma)^2)*(dt)+sigma*sqrt(dt)*z)
end
end
ABhttps://fr.mathworks.com/matlabcentral/profile/authors/14656524-abtag:fr.mathworks.com,2005:Question/4297642018-11-14T08:43:07Z2020-03-31T03:00:43ZHow to solve error message in fsolve stating: "The vector of function values is near zero, as measured by the selected value of the function tolerance. However, the last step was ineffective"Dear all, I am trying to solve transcendental equations of TM mode using fsolve, but I constantly get error message stating:
"The vector of function values is near zero, as measured by the selected value of the function tolerance. However, the last step was ineffective."
Here are the code and myfun fiels, please help me!
Thxs!
% Given:
clear;clc;
mu_o = 4*pi*10^(-7);
mu_r = 1;
esp_o = (10^(-9))/(36*pi);
esp_r = 2.56;
esp_d = esp_o*esp_r;
mu_d = mu_o*mu_r;
h = 0.3175; % [cm]
f_c1 = 18.913e9; % from example 8-11 pp 17.
f = 0:f_c1/1000:2*f_c1;
b_z = 0; %Initialization
for f_index = 1:1:length(f)
w = (2*pi*f(f_index));
b_z = 793; % Initial point guessing
options = optimset('Display','iter','MaxFunEvals',1e20,'TolFun',1e-10,'TolX',1e-10);
b_z_sol = fsolve(@myfun, b_z, options);
end
b_yd_sol = (sqrt(w.^2*mu_d*esp_d - b_z_sol.^2))/100; % [rad/cm] equ. 8-160c
a_sol = (sqrt(b_z_sol.^2 - (w.^2*mu_o*esp_o)))/100; % [rad/cm] equ. 8-160d
b_o = w*sqrt(mu_o*esp_o);
b_d = w*sqrt(mu_d*esp_d);
% Figure-a
subplot(2,1,1);
plot(f(f_index)/f_c1,real(b_z_sol));
hold on;
plot(f(f_index)/f_c1, real(b_yd_sol), ':');
plot(f(f_index)/f_c1, real(a_sol), '--');
hold off;
axis([0 f(f_index)/f_c1 0 9]);
xlabel('Normalized frequency (f/f_C_1)');
title('Attenuation and Phase Constants of TM^{Z}_m');
subplot(2,1,2);
% Figure-b
plot(b_o, w);
hold on;
plot(b_d, w);
plot(real(b_z_sol), w);
axis([0 13e2 0 2e11]);
xlabel('\beta_o \beta_z \beta_d');
ylabel('\omega(\beta_o \beta_z \beta_d)');
title('Dispersion Curve');
hold off;
% myfum.m file code:
function F = myfun(b_z)
global w;
mu_o = 4*pi*10^(-7);
mu_r = 1;
esp_o = (10^(-9))/(36*pi);
esp_r = 2.56;
esp_d = esp_o*esp_r;
mu_d = mu_o*mu_r;
h = 0.3175; % [cm]
f_c1 = 18.913e9; % from example 8-11 pp 417
f = 0:18.913e6:2*f_c1;
for f_index = 1:1:length(f)
end
w = (2*pi*f(f_index));
% Iteration equations for the three unknowns
b_yd = (sqrt(w.^2*mu_d*esp_d - b_z.^2))/100; % [rad/cm] equ. 8-160c
a = (sqrt(b_z.^2 - (w.^2*mu_o*esp_o)))/100; % [rad/cm] equ. 8-160d
F = (a*(esp_d/esp_o)) - (b_yd*h*tan(b_yd*h)); % equ 8-160b
end
Yonas Gezahegnhttps://fr.mathworks.com/matlabcentral/profile/authors/12080314-yonas-gezahegntag:fr.mathworks.com,2005:Question/5141742020-03-31T02:41:38Z2020-03-31T03:00:42ZSingle line of code for vectorization, Need Help!!
Hi there, I need to write just one line of code in order to calculate the corresponding volumes of cones fromed from a vector r of radii and a vector h of heights. Using V =1/3pir^2h for the volume of a cone im supposed to make just ONE line of code in matlab that satisfies this. It says r and h are should be assumed to be row vectors and can be any size.
Here is my code which is probably way off and the grader file i have says it is incorrect. I also have the original question attached.
V = 1/3*pi*r.^2.*h ;Alex Platthttps://fr.mathworks.com/matlabcentral/profile/authors/18001902-alex-platttag:fr.mathworks.com,2005:Question/5141722020-03-31T02:09:02Z2020-03-31T02:52:29ZFinding the displacement from the image sequences/framesI have a MP4 video which has a moving object. From the video, i have extracted the frames of about 960. From the extracted frames, have to select a rectangular roi with centroid point. From the centroid selected, i want to find the x and y displacement. How can I proceed further?Studenthttps://fr.mathworks.com/matlabcentral/profile/authors/17944898-studenttag:fr.mathworks.com,2005:Question/5141092020-03-30T20:00:50Z2020-03-31T02:51:25ZHow to create a menu with checkbox in app designer?Hi everyone,
I've been working on a gui in app designer for a while now. I'd like to add a top menu bar feature that contains a dropdown menu with four different fields. In each field, I'd like there to be at least two checkboxes. The purpose is for the user to select which units they'd like for their data to be processed and plotted (see image below).
I plan on using the checkbox to indicate which option is selected in each menu, as well as editing a public property that contains conversions to use within some code. When one checkbox is selected in each sub menu, I'd also like to deselect the other checkboxes within the same submenu
(e.g. distance> meters[x], feet[ ] --> distance> meters[ ], feet [x])
I've read the matlab documentation from this link https://www.mathworks.com/help/matlab/ref/uimenu.html, but I don't understand how to create the checkbox option in app designer.
Can someone explain to me how to do so in design view/code view ?
Sample of menu (meters and feet should be checkboxes):
rtbme17https://fr.mathworks.com/matlabcentral/profile/authors/10488096-rtbme17tag:fr.mathworks.com,2005:Question/5141682020-03-31T01:15:14Z2020-03-31T02:47:40ZMultiple conditional statements with logicI want to write a function called under_age that inputs whether a person is too young or not. It has multiple inputs of age and limit.
If the age is less than the limit than too_young = true and if age is greater than too_young = false. I also want to put in a case when the age is inputed
In which case, the age is of the limit of automatically set to 21.
At the moment the function works if the person is too_young = true. But I can't figure out why it doesn't work when too_young = false.
function [too_young] = under_age(age, limit)
if (nargin == 2)
age < limit
too_young = true;
elseif (nargin == 2)
age >= limit
too_young = false;
elseif (nargin == 1) || isempty(limit)
age < 21
too_young = true;
elseif (nargin == 1) || isempty(limit)
age >= 21
too_young = false;
endThomas Sunhttps://fr.mathworks.com/matlabcentral/profile/authors/17957432-thomas-suntag:fr.mathworks.com,2005:Question/4376352018-12-29T21:28:42Z2020-03-31T02:47:34Zmexcuda not finding CUDA 10.0 even after I specify it via setenv('MW_NVCC_PATH',...)I have set the path of MW_NVCC_PATH to setenv('MW_NVCC_PATH','C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin')
If I do a verbose mexcuda
Trying MEX options 'C:\Program Files\MATLAB\R2018b\toolbox\distcomp\gpu\extern\src\mex\win64\nvcc_msvcpp2017.xml'...FAILED
Trying MEX options 'C:\Program Files\MATLAB\R2018b\toolbox\distcomp\gpu\extern\src\mex\win64\nvcc_msvcpp2015.xml'...FAILED
Trying MEX options 'C:\Program Files\MATLAB\R2018b\toolbox\distcomp\gpu\extern\src\mex\win64\nvcc_msvcpp2013.xml'...FAILED
Trying MEX options 'C:\Program Files\MATLAB\R2018b\toolbox\distcomp\gpu\extern\src\mex\win64\nvcc_msvcpp2012.xml'...FAILED
Warning: No supported host compiler found, or other problem with the environment.
Continuing with selected compiler to provide detailed diagnosis.
> In mexcuda (line 130)
mex -largeArrayDims -f C:\Program Files\MATLAB\R2018b\toolbox\distcomp\gpu\extern\src\mex\win64\nvcc_msvcpp2017.xml NVCC_FLAGS="" -v mexGPUExample.cu
Verbose mode is on.
... Looking for compiler 'NVIDIA CUDA Compiler' ...
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 15.0 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 15.0 ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' 15.0 ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\').
... Executing command 'set "vcroot=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise"&for /f "delims= " %a in ('type "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt"') do @if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\%a\bin\HostX64\x64\cl.exe" call echo %vcroot%' ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise').
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0' InstallationFolder ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0' InstallationFolder ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0' InstallationFolder ...Yes ('C:\Program Files (x86)\Windows Kits\10\').
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 15.0 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 15.0 ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' 15.0 ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\').
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 15.0 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 15.0 ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' 15.0 ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\').
... Executing command 'set "vcroot=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise"&for /f "delims= " %a in ('type "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt"') do @if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\%a\bin\HostX64\x64\cl.exe" call echo %vcroot%\VC\Tools\MSVC\%a' ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023').
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 15.0 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 15.0 ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' 15.0 ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat' ...Yes.
... Looking for folder 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build' ...Yes.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows Kits\Installed Roots' KitsRoot10 ...Yes ('C:\Program Files (x86)\Windows Kits\10\').
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows Kits\Installed Roots' KitsRoot10 ...Yes ('C:\Program Files (x86)\Windows Kits\10\').
... Executing command 'echo off&set "sdkversion="&(for /f %a IN ('dir "C:\Program Files (x86)\Windows Kits\10\include\" /b /ad-h /on') do ( @if exist "C:\Program Files (x86)\Windows Kits\10\include\%a\ucrt\" set "sdkversion=%a" ))&call echo %sdkversion%' ...Yes ('10.0.17763.0').
... Looking for environment variable 'MW_NVCC_PATH' ...Yes ('C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin').
... Looking for file 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\lib\x64\cudart.lib' ...Yes.
... Looking for folder 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\lib\x64' ...Yes.
... Looking for environment variable 'MW_NVCC_PATH' ...Yes ('C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin').
... Looking for file 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin\nvcc.exe' ...Yes.
... Executing command 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin\nvcc --version | findstr /c:"release 9.1" > NUL && echo C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin' ...No.
... Looking for environment variable 'MW_NVCC_PATH' ...Yes ('C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin').
... Looking for file 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin\nvcc.exe' ...Yes.
... Executing command '"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin\nvcc" --version | findstr /c:"release 9.1" > NUL && echo C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin' ...No.
Did not find installed compiler 'NVIDIA CUDA Compiler'.
Warning: Version 9.1 of the CUDA toolkit could not be found. If installed, set MW_NVCC_PATH environment variable
to location of nvcc compiler.
> In mexcuda (line 157)
Error using mex
No supported compiler was found. For options, visit https://www.mathworks.com/support/compilers.
Error in mexcuda (line 157)
[varargout{1:nargout}] = mex(mexArguments{:});Naveen kumar Elumalaihttps://fr.mathworks.com/matlabcentral/profile/authors/11345752-naveen-kumar-elumalaitag:fr.mathworks.com,2005:Question/5141352020-03-30T21:13:16Z2020-03-31T02:46:53ZHow to find the distance of a point to a line (knowing all the points)?Hi!!
I have a line made of two points BA and a point P. I would like to find the distance from P to the perpendicular of BA and to the parallel of BA.
Do you know if there is any fuction aready doing it?
I attacht a picture to make it easier to understand.
Thanks in advance.Daniel Jarahttps://fr.mathworks.com/matlabcentral/profile/authors/12068703-daniel-jaratag:fr.mathworks.com,2005:Question/1000662012-07-06T14:34:00Z2020-03-31T02:38:37ZHow do I create a logarithmic scale colormap or colorbar?I need to color SURF plots on a log scale and subsequently displace the log-based colorbar.
MathWorks Support Teamhttps://fr.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:fr.mathworks.com,2005:Question/5138702020-03-30T06:12:53Z2020-03-31T02:34:32ZNeed matlab coding for the given c program#include <stdio.h>
int main()
{
char a[100];
int i;
i=0;
scanf("%c",&a[i]);
while(a[i]!='$')
{
i++;
scanf("%c",&a[i]);
}
a[i]='\0';
i=0;
while(a[i]!='\0')
{
printf("%c",a[i]);i++;
}
return 0;
}
leo johnhttps://fr.mathworks.com/matlabcentral/profile/authors/17582084-leo-johntag:fr.mathworks.com,2005:Question/5141702020-03-31T01:30:36Z2020-03-31T02:33:25Zintegrate a simple functionMatlab grader keeps saying err has incorrect valueJesus Molinahttps://fr.mathworks.com/matlabcentral/profile/authors/17288790-jesus-molinatag:fr.mathworks.com,2005:Question/5141732020-03-31T02:28:14Z2020-03-31T02:28:14Z[Need help!] All help, app, addon-manager get blank pages?Hi, I dont know whether someone else got this issue, on my computer with NVIDIA RTX2060, all docs and apps get just blank front page and nothing is shown like following. Can anyone help?
Song Decnhttps://fr.mathworks.com/matlabcentral/profile/authors/10395652-song-decntag:fr.mathworks.com,2005:Question/5141332020-03-30T20:57:19Z2020-03-31T02:26:27ZHow to Allow User Image Upload on App Designer.Im trying to create an app using the app designer and i would like to give the user the option to upload an image, how can i do that and if possible what would the code for it be.
Please Advise,
Thank You,abdulla alyammahihttps://fr.mathworks.com/matlabcentral/profile/authors/11122292-abdulla-alyammahitag:fr.mathworks.com,2005:Question/5141312020-03-30T20:50:03Z2020-03-31T02:20:19ZMatlab syntax (vectorization)Dear all,
i have a simple question that's been bothering me for a while:
For example there is a data array A of size
[size_a,size_b,size_c]=size(A);
and a logical array B with size
[size_a,size_b]=size(B);
Is it possible to query the first two dimensions of Array A with array B without reshaping?
Suppose i want to do something like
C(:,:)=A(B(:),:);
which does not work. Solution would be
D=reshape(A,[size_a*size_b,size_c]);
C(:,:)=D(B(:),:);
RegardsFabian Föllhttps://fr.mathworks.com/matlabcentral/profile/authors/2208874-fabian-folltag:fr.mathworks.com,2005:Question/5141432020-03-30T21:46:32Z2020-03-31T02:14:34ZIs it possible to assign keyboard shortcuts to trigger certain parts of my app in app designer, and if so, how?I was wondering if it's possible to assign user defined keyboard shortcuts to parts of the app in app designer.
For example,using a menu item with ctrl+L, or simply just L. Not sure if this is possible, but if anyone knows, please share
Thanks!rtbme17https://fr.mathworks.com/matlabcentral/profile/authors/10488096-rtbme17tag:fr.mathworks.com,2005:Question/5127222020-03-24T20:01:05Z2020-03-31T02:03:36Zhow to write these two equationsSultan Al Harthyhttps://fr.mathworks.com/matlabcentral/profile/authors/17062302-sultan-al-harthytag:fr.mathworks.com,2005:Question/5141692020-03-31T01:17:33Z2020-03-31T02:02:21ZHow to plot contur in 3 DI have a result calculation and I want to make plot contur in 3 D. From the excel files attxhed I also plot in two dimension of FzWz vs Depth
What is the appropriate Matlab function to create contur in 3 D of FzWz vs Depth
I attach the data file about the data.
Thank you for your kind attention
Akhmad Muktafhttps://fr.mathworks.com/matlabcentral/profile/authors/7503568-akhmad-muktaftag:fr.mathworks.com,2005:Question/5134192020-03-27T16:58:45Z2020-03-31T02:00:41ZQuadratically constrained linear maximisation problem: issues with fminconI would like to solve the following quadratically constrained linear programming problem.
I have written a Matlab code (R2091b) that solve the problem using Gurobi. Now, I would like to rewrite the code using fmincon instead of Gurobi. This is because the optimisation problem will have to be solve thousands of times and Gurobi's academic license does not allow to parallelise via array jobs in a cluster. However, I'm encountering a huge problem: Gurobi takes 0.23 second to give a solution, fmincon takes 13 sec. I suspect this should be due to my mistakes/inefficiences in providing gradient, hessian, etc. Could you kindly help me to improve below?
Also, Gurobi gives me 0.2 as solution, fmincon gives 0.089. Can the accuracy of fmincon be improved without trying other starting points?
This is my code with Gurobi
clear
rng default
load matrices
%1) GUROBI
model.A=[Aineq; Aeq];
model.obj=f;
model.modelsense='max';
model.sense=[repmat('<', size(Aineq,1),1); repmat('=', size(Aeq,1),1)];
model.rhs=[bineq; beq];
model.ub=ub;
model.lb=lb;
model.quadcon(1).Qc=Q;
model.quadcon(1).q=q;
model.quadcon(1).rhs=d;
params.outputflag = 0;
result=gurobi(model, params);
max_problem_Gurobi=result.objval;
This is my code with fmincon
%2) FMINCON
options = optimoptions(@fmincon,'Algorithm','interior-point',...
'SpecifyObjectiveGradient',true,...
'SpecifyConstraintGradient',true,...
'HessianFcn',@(z,lambda)quadhess(z,lambda,Q));
fun = @(z)quadobj(z,f.');
nonlconstr = @(z)quadconstr(z,Q,d);
[~,fval] = fmincon(fun,z0,Aineq,bineq,Aeq,beq,lb,ub,nonlconstr,options);
max_problem_fmincon=-fval;
function [y,yeq,grady,gradyeq] = quadconstr(z,Q,d)
y= z'*Q*z -d;
yeq = []; %no quadratic inequalities
if nargout > 2
grady = 2*Q*z;
end
gradyeq = []; %no quadratic inequalities
end
function hess = quadhess(z,lambda,Q) %#ok<INUSL>
hess = 2*lambda.ineqnonlin*Q;
end
function [y,grady] = quadobj(z,f)
y = -f'*z;
if nargout > 1
grady = -f;
end
Further, if I run the code with fmincon with as starting point the optimal point given by Gurobi, I still get the solution 0.089 (instead of 0.2 as in Gurobi). Why?
%3) FMINCON
z0=result_Gurobi.x;
options = optimoptions(@fmincon,'Algorithm','interior-point',...
'SpecifyObjectiveGradient',true,...
'SpecifyConstraintGradient',true,...
'HessianFcn',@(z,lambda)quadhess(z,lambda,Q));
fun = @(z)quadobj(z,f.');
nonlconstr = @(z)quadconstr(z,Q,d);
[~,fval] = fmincon(fun,z0,Aineq,bineq,Aeq,beq,lb,ub,nonlconstr,options);
max_problem_fmincon=-fval;
function [y,yeq,grady,gradyeq] = quadconstr(z,Q,d)
y= z'*Q*z -d;
yeq = []; %no quadratic inequalities
if nargout > 2
grady = 2*Q*z;
end
gradyeq = []; %no quadratic inequalities
end
function hess = quadhess(z,lambda,Q) %#ok<INUSL>
hess = 2*lambda.ineqnonlin*Q;
end
function [y,grady] = quadobj(z,f)
y = -f'*z;
if nargout > 1
grady = -f;
end
end
CThttps://fr.mathworks.com/matlabcentral/profile/authors/10950381-cttag:fr.mathworks.com,2005:Question/5136022020-03-28T17:42:10Z2020-03-31T01:58:56ZHow to calculate root mean square error for multi-output data for neural network?I have a 3-input and 3 -output neural network to be trained. How to code the calculation part of root means square error for multi-output data in neural network? And plot them. Can any one help me to solve the problem? Thanks.Hong Kai Bonghttps://fr.mathworks.com/matlabcentral/profile/authors/12692391-hong-kai-bongtag:fr.mathworks.com,2005:Question/5138332020-03-29T23:59:05Z2020-03-31T01:56:06ZHow to calculate the highest consecutive negative results in my codeHi,
I'm new to Matlab and I have been having help to write this code. I am trying to learn on my own and I am trying now to write something that would calculate the highest consecutive negative results in my code. I would be happy to recieve some help!
clear variables
k = 5000;
risk = 0.007;
riskM = 0.1;
maxR = 0.022;
numberSteps = 105;
markets = zeros(numberSteps,1);
markets(1) = k;
for i = 1:size(markets,1) - 1
markets(i+1) = markets(i)*(1+0.1);
end
% ka = 1100
%%
numberSim = 1000;
distR = randsrc(numberSteps, numberSim,[-1 -.6 -.36 -.07 0 0.17 0.37 0.39 0.5 0.81 1.37 1.39 1.4 2.2 2.57 3.16 3.55 5.49 6.56 7.34 7.82 8.63 8.7 9.15 9.42 11.55 17.94 19.9 21.18 22.28 28.4 28.51;...
.648 .0095 .0095 .0095 0.067 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095 .0095]);
cumR = cumsum(distR,1);
MaxD = maxdrawdown(cumR,'arithmetic');
[maxMaxD,ii] = max(MaxD);
meanD = mean(MaxD);
stdD = std(MaxD);
figure
subplot(1,2,1)
plot(cumR)
subplot(1,2,2)
plot(cumR(:,ii))
sgtitle(['Mean Drawdown=',num2str(meanD,3),' std=',num2str(stdD,3), ' Max Possible DD=',num2str(maxMaxD,3)])Camilo Acevedohttps://fr.mathworks.com/matlabcentral/profile/authors/17986626-camilo-acevedotag:fr.mathworks.com,2005:Question/5140672020-03-30T18:06:49Z2020-03-31T01:54:43ZCreate a model to solve an energy balance Hi, I am trying to use MATLAB to create a model that can solve a set of equations. I have attached an image of the equations I am trying to solve. Essentially, there are 3 unknowns, Tout, Tp & Tg.
I wanted to ask which would be the best way to solve this on MATLAB, i have tried to use matrices but the temperatures I am getting are very high. Is there any other method that could be used to solve these equations?
Kind regardskasimhttps://fr.mathworks.com/matlabcentral/profile/authors/8999886-kasimtag:fr.mathworks.com,2005:Question/2660792016-02-01T15:02:08Z2020-03-31T01:54:16ZPlot two figures in one figureI have my own function called 'histogram_with_mean_sigma_lines'. The output of the function is a figure. So I use this function to generate two figures (which is a histogram). I want the two figures to be in one figure like two subplot (2,1,1 & 2,1,2).Praveen Choudhuryhttps://fr.mathworks.com/matlabcentral/profile/authors/6382237-praveen-choudhurytag:fr.mathworks.com,2005:Question/2583322015-12-01T06:48:38Z2020-03-31T01:47:40ZIs it possible to increase the font of the Simulink Library Browser?Sometimes when I'm demonstrating an exercise on Simulink to a class, I pull out the Simulink Library Browser. Unfortunately the font is rather small.
Is it possible to increase it? I've tried searching Preferences -> Simulink -> Open Simulink Preferences but did not come across a font editor for the library.Estherhttps://fr.mathworks.com/matlabcentral/profile/authors/5843831-esthertag:fr.mathworks.com,2005:Question/5141662020-03-31T00:43:36Z2020-03-31T01:46:25ZComparing numerical values of a 5x2 cellHello,
I am trying to compare all values in a 5x2 array that are below a certain threshold, and preserve the corresponding data in its particular row. For example, let's say I have a total of 5 cars but need to check which car goes a certain speed. I have a 5x2 matrix where the first column is a string and the second column are integers. I need to develop an algorithm that will return each of the cars that is below a a certain speed, say, below equal to or below 55 mph:
Red Car 50
Blue Car 45
Green Car 30
Black Car 60
Yellow Car 55
Therefore my output would need to be:
Red Car 50
Blue Car 45
Green Car 30
Yellow Car 55
I am guessing that the best way to do this will be with a few loops and an if statement to check the condition, but I am just not sure how to go about this as I am pretty new to MatLab. Any tips would be appreciated.
Thanks,
Patrick Pathttps://fr.mathworks.com/matlabcentral/profile/authors/17325667-pattag:fr.mathworks.com,2005:Question/5129712020-03-25T21:44:20Z2020-03-31T01:41:04ZFinding Area of Polygon defined by roipolyHello,
I would like to know how I can use the function polyarea to find the area of a region defined by the function roipoly.
I am new to image processing with matlab and basically what I am trying to do is read an image, select a border for something within the image using roipoly, finding the area within the border in pixels and finally converting the area in pixels to area in m^2. Please advise.
Thank you,abdulla alyammahihttps://fr.mathworks.com/matlabcentral/profile/authors/11122292-abdulla-alyammahitag:fr.mathworks.com,2005:Question/5139662020-03-30T13:30:18Z2020-03-31T01:38:34ZFitting a profile to a Guassian ModelHi there, I am trying to find an expression for the parameter 'alpha' as a function of x (the length): alpha = f(x). Means that alpha must be estimated as a profile, rather than a data point. My alpha is dependent on 4 experimental and independent variables (Temperature T, Pressure P, mass flow rate m and ratio R) which each of them individually affect this profile.
I tried to use a 3rd order polynom for its description. Alpha = A x^3 + B x ^2+ C x + D.
In order to take the influence of these 4 variables on alpha values, I have written the 4 factors of A, B, C and D as:
A = a(1) * T ^ a(2) + a(3) * P ^ a(4) + a(5) * m ^ a(6) + a(7) * ratio ^ a(8) + a(9)
B = b(1) * T ^ b(2) + b(3) * P ^ b(4) + b(5) * m ^ b(6) + b(7) * ratio ^ b(8) + b(9)
C = c(1) * T ^ c(2) + c(3) * P ^ c(4) + c(5) * m ^ c(6) + c(7) * ratio ^ c(8) + c(9)
D = d(1) * T ^ d(2) + d(3) * P ^ d(4) + d(5) * m ^ d(6) + d(7) * ratio ^ d(8) + d(9)
I try to fit my experimental data with lsqnonlin, levenberg-marquardt algorithm and find the above mentioned 36 variables, so that I can have an expression for A, B, C and D, to finally predict alpha. But my problem is that: 1st: I think it’s very inefficient to use 36 parameters for a function, but I just have no better idea!! 2nd: the solver does converge and I find my 36 values (local minimum possible). But when I calculate alpha the value it gives me is going below zero (which is wrong).. and also is not really correct..
Instead I would like to use a Gaussian function to do the fit, since it describes the decaying trend of alpha better (in the attachment) and doesnt go to below zero either, but I cannot find what is the corresponding function for 'polyfit' for a Gaussian fit, and if it helps to reduce the number of the parameters and improve the accuracy..
I would greatly appreciate any comments or hints from both mathematical and coding point of view
Sarvhttps://fr.mathworks.com/matlabcentral/profile/authors/10325261-sarvtag:fr.mathworks.com,2005:Question/5141672020-03-31T01:10:57Z2020-03-31T01:28:20Zsystem of non linear equations how can I solve these equations
eqn1= a+b=4;
eqn2= 2d+2e=10;
eqn3= 2a+b+d+2f=13.684;
eqn4= (1/(34.726+f))^0.5*((4-a)*f^0.5)/a=kp1;
eqn5= (5/(9.684-a-2f)-1)*f^0.5*(1/(34.726+f))^0.5=kp2;
when
lnkp2 = [-106.208,-60.281,-26.034,-20.283,-16.099,-13.066,-10.657,-8.728,-7.148,-5.832];
kp2 = exp(lnkp2);
lnkp1 = [-103.762,-57.616,-23.529,-17.871,-13.842,-10.83,-8.497,-6.635,-5.12,3.86];
kp1 = exp(lnkp1);Abdelrahman Eldalyhttps://fr.mathworks.com/matlabcentral/profile/authors/15707120-abdelrahman-eldalytag:fr.mathworks.com,2005:Question/5132692020-03-27T04:05:00Z2020-03-31T01:20:18ZIdentifying the circle that fits the outer white pixels in a binary image (or make external mask)Hi all,
I want to process a series of images similar to the attached one in order to measure their porosities: V_pores / V_total. For my case, in a 2D context, V_total is the surface of circle containing all pores. It is important to know that the radius and center of the circle changes, and also many circular shapes can be identified in between, however, I am only interested, at this moment, in measuring the general surface of the circle (Vt).
Alernatively, I would be interested in applying a mask to the image. But it seems to be more difficult.
Any help would be appreciated. Many thanks.Dyhia Bouhadjrahttps://fr.mathworks.com/matlabcentral/profile/authors/17127436-dyhia-bouhadjratag:fr.mathworks.com,2005:Question/489382012-09-24T10:06:12Z2020-03-31T01:13:06Zdelete element from vectorHi everyone
how can I delete element from vector .... for example
a=[1,2,3,4,5]
how can I delete 3 from above vector to be
a=[1,2,4,5]
thank you
majidMajid Al-Sirafihttps://fr.mathworks.com/matlabcentral/profile/authors/3266642-majid-al-sirafitag:fr.mathworks.com,2005:Question/5141612020-03-30T23:47:47Z2020-03-31T01:08:53ZHelp with non working for loop for generating a matrixclc;clf;clear;
A = zeros(2,2);
c = 0:0.1:2.23;
for x=(4-c)./(6+c)
y=10./(6+c);
A =[-1-2.*x(c)+y(c) x(c);-6.*y(c) 4-2.*c.*y(c)-6.*x(c)];
end
I am trying to plot a graph of trace-determinant of mmatrix A, where I am in need of the values of x and y varying with c in my matrix A.
The result is a vector of 0's, Values of y and care displayed fine but only one value of x in one iteration of c.
Array indices must be positive integers or
logical values.
Error in Untitled7 (line 8)
A =[-1-2.*x(c)+y(c) x(c);-6.*y(c)
4-2.*c.*y(c)-6.*x(c)];Shing-Hei Tohttps://fr.mathworks.com/matlabcentral/profile/authors/16989696-shing-hei-totag:fr.mathworks.com,2005:Question/3884652018-03-15T10:31:53Z2020-03-31T01:02:04ZI want to save multiple images in a folder?I made the code but the looping variable comes in the string function so a single image is saved in the folder. Is any other way of separating the looping variable from the colon bars.
img=imread('cameraman.tif');
for i=1:5
img=imread('http://satellite.imd.gov.in/img/3Dnesec_ir1.jpg')
imwrite(img,'D:\output database\i.jpg','jpg')% x be a image to write
end
Shashank Srivastavahttps://fr.mathworks.com/matlabcentral/profile/authors/8877891-shashank-srivastavatag:fr.mathworks.com,2005:Question/5138782020-03-30T07:01:53Z2020-03-31T00:59:20ZCan we upload image to Thingspeak?Current situation:
I have saved my processed image in raspberry pi. I would like to upload the image to Thingspeak. However, I came across some posts saying that we cant upload image to Thingspeak. I wish to view my image at Thingspeak and also at Thingview(mobile app).
Questions:
1) Can we upload image to Thingspeak?
2) Or can i upload the image to Google Drive then link it back to Thingspeak ?
3) If no, any way to do it?
This is the example that show the image, but I not sure how it does.
https://thingspeak.com/channels/276330Mei Sing Wanghttps://fr.mathworks.com/matlabcentral/profile/authors/15397490-mei-sing-wangtag:fr.mathworks.com,2005:Question/5139922020-03-30T14:38:25Z2020-03-31T00:49:42Zgenetic algorithm for rankexcuse me, I may ask whether genetic algorithms can be used to rank multiple variables?
i have case to do rank the data with genetic algorithm from the highest value
can you help me please? thank's before
joni nababanhttps://fr.mathworks.com/matlabcentral/profile/authors/17552522-joni-nababantag:fr.mathworks.com,2005:Question/5141592020-03-30T23:45:28Z2020-03-31T00:48:32ZHow to find following integral answer in matlab Dear scholars,
I need to find soln of integral:
int((f1(x))^3 * f2(x), x, 0, L)
but matlab can not solve it,
Any ideas?
I also attach the code here
(fi(x) are all combintaions of trigonometrix and hyperbolic functions, and due to orthogonality we know that int(f1(x) * f2(x), x, 0, L)) = 0, but I need to make sure whenever the first function is cubed)
clc
clear all
close all
format long
L = 100e-3;
Areap = 2*(b*hp);
Areas = b*hs;
Areat = Areas + Areap;
roAt = ros*Areas + rop*Areap;
landaL = [1.875104, 4.694091, 7.854757];
landa = landaL./L;
syms x
a1 = (cosh(landaL(1)+cos(landaL(1))));
a2 = (sinh(landaL(1))+sin(landaL(1)));
% phi = (1/sqrt(roAt*L)) * (cosh(landa*x)-cos(landa*x)-(a1/a2)*(sinh(landa*x)-sin(landa*x)));
phi(1) = (1/sqrt(roAt*L)) * (cosh(landa(1)*x)-cos(landa(1)*x)-(a1/a2)*(sinh(landa(1)*x)-sin(landa(1)*x)));
b1 = (cosh(landaL(2)+cos(landaL(2))));
b2 = (sinh(landaL(2))+sin(landaL(2)));
% phi = (1/sqrt(roAt*L)) * (cosh(landa*x)-cos(landa*x)-(a1/a2)*(sinh(landa*x)-sin(landa*x)));
phi(2) = (1/sqrt(roAt*L)) * (cosh(landa(2)*x)-cos(landa(2)*x)-(b1/b2)*(sinh(landa(2)*x)-sin(landa(2)*x)));
% A01 = round(int(roAt*phi(1)*phi(1),x,0,L))
A11 = round(int(roAt*phi(1)*phi(2),x,0,L))
% A11 is = 0 showing and proving the orthogonality trait ...
A21 = int(roAt*(phi(1)^2)*phi(2),x,0,L)
%A21 = round(int(roAt*(phi(1)^2)*phi(2)),x,0,L)
Alireza Babaeihttps://fr.mathworks.com/matlabcentral/profile/authors/17771320-alireza-babaeitag:fr.mathworks.com,2005:Question/5141642020-03-31T00:20:31Z2020-03-31T00:35:15ZParse/Syntax ErrorI am writing a simple functin to solve for a frequency (OmegaD) and cannot figure out what the problem is, although it says it's an issue with syntax.
The name of the file: Parametros2doOrden.m
Here's the code:
Lamda = 0.3333
OmegaN= 3
OmegaD = OmegaN(sqrt(1-(lamda**2));
The error shown in the command window is the following:
>> Parametros2doOrden
parse error near line 3 of file /Users/guzmanleo17/Parametros2doOrden.m
syntax error
%tiempoP = pi/omegad;megad;mda**2)));
^Angel Guzmanhttps://fr.mathworks.com/matlabcentral/profile/authors/18001541-angel-guzmantag:fr.mathworks.com,2005:Question/4899642019-11-08T10:58:37Z2020-03-31T00:33:53ZContinuity Constraint in a Optimization ProblemI'm working on an optimization algorithm and I should insert a continuity constraint on a variable x to be optimized. In other words, I have some appliances and I have to match active/off periods. This is my optimization variable :
x = optimvar('x',8,24,'Type','integer','LowerBound',0,'UpperBound',1);
I have to try to write a constraint to keep appliances running consecutively. How can I do?VBhttps://fr.mathworks.com/matlabcentral/profile/authors/15030988-vbtag:fr.mathworks.com,2005:Question/5119902020-03-20T19:22:32Z2020-03-31T00:29:51ZHow can I format the datetime when the format is not recognized?Hello, I'm having some trouble setting my datetime format. The original timestamps I get looks like this "0200310T102613000" and I've tried to format it like this;
p1 = readtable('10.csv');
date1 = table2cell(p1(:,1));
dateT = datetime(date1,'InputFormat','YYYYmmdd''T''HHmmssSSS');
I've even tried removing the date secion (i.e. "102613000") and running is like this;
dateT = datetime(date1,'InputFormat','HHmmssSSS');
However I always get an error using the datetime function. Does anyone have any ideas for me?
Thanks!Jade O'Brien-Smithhttps://fr.mathworks.com/matlabcentral/profile/authors/15229765-jade-o-brien-smithtag:fr.mathworks.com,2005:Question/5141582020-03-30T23:44:18Z2020-03-31T00:29:37ZSolving a system of second order differential equations I get the following error message when I run the code below (although this error does not always occur; sometimes the plot is generated). I do not see why because matlabFunction (for example, in the line "M = matlabFunction(V,'vars', {'t','Y'})" (source: https://www.mathworks.com/help/symbolic/solve-differential-equation-numerically-1.html)) is a standard name.
Error message
Error using sym/matlabFunction>checkVars (line 223)
Variable names must be valid MATLAB variable names.
Error in sym/matlabFunction (line 158)
vars = checkVars(funvars,opts);
Code
syms y(t) z(t )
Dy = diff(y,t );
Dz = diff(z,t );
eqns = [diff(y,t,2) == (29.4*cos(z)+4*Dz*Dz)*sin(z)/(1+3*sin(z)*sin(z )),...
diff(z,t,2) == -3*(19.62+2*Dz*Dz*cos(z))*sin(z)/(2*(1+3*sin(z)*sin(z )))];
fun = matlabFunction(odeToVectorField(eqns),'Vars',{'t','Y '});
tspan = [0 10]; % Time interval for integration
y0 = [0 1 0 1]; % initial conditions
[t,y] = ode45(fun,tspan,y0 );
plot(t,y)
Aleem Andrewhttps://fr.mathworks.com/matlabcentral/profile/authors/13655223-aleem-andrewtag:fr.mathworks.com,2005:Question/5134912020-03-28T01:40:44Z2020-03-31T00:29:34ZHow to get intlinprog to stop when the answer is good enough?The code below finds an maximum independent set of the graph whose adjacency matrix is A. I would like to pass an option to intlinprog that says stop and return an answer if you get an objective value of -5 or less (meaning an independent set of size 5 or more has been found). This should be much more efficient than finding an independent set of maximum size.
If there is no option to pass to intlinprog that can accomplish my goal, then is there another approach that will?
n = 20;
A = rand(n, n) < 0.1;
A = A | A.';
[r, c] = find(A);
m = numel(r);
B = zeros(m, n);
for eI = 1 : m
B(eI, [r(eI), c(eI)]) = 1;
end
b = ones(m, 1);
c = -ones(n, 1);
% min cost.' * x subject to A * x <= b, x(i) is 0 or 1 for all i.
lb = zeros(n, 1);
ub = lb + 1;
intvars = 1 : n;
options = optimoptions('intlinprog','Display','off');
[x, fval, exitflag, output] = intlinprog(c, intvars, B, b, [], [], lb, ub, options);
Jonathanhttps://fr.mathworks.com/matlabcentral/profile/authors/1736562-jonathantag:fr.mathworks.com,2005:Question/5141652020-03-31T00:23:08Z2020-03-31T00:23:08ZUsing Matlab Grader to check correct name-value pair was usedI'm using Matlab Grader for the very first time. I want to use it for a statistics class, so I'm using the statistics package with Matlab. Many of the commands are correct only if you use the correct name-value pair. For example, if I want to do a two-sample t-test for samples with unequal variance I must specify the following command:
ttest2(x1,y,'Vartype','unequal')
I can easily use Matlab Grader to check that they function ttest2 was used, but I also want to confirm the students used the correct 'Vartype'. How do I create a test in Matlab Grader for that?
Angela Joneshttps://fr.mathworks.com/matlabcentral/profile/authors/11990480-angela-jonestag:fr.mathworks.com,2005:Question/4825542019-09-27T23:25:56Z2020-03-31T00:10:29ZFiltering in the frequency domainHello everyone,
I am just getting into matlab and and working through some projects for digitam image processing. I wrote some matlab code to filter in the frequency domain but when I plot my image at multiple points I am getting issues from the expected results. I believe the issues are plotting and data type related and wanted to get some feedback on how to do things better.
I need to accomplish the following:
Given an input f(x,y) of size M x N obtain the padding sizes P and Q. P = 2M, Q = 2N.
Form a padded image fp(x,y) of size P x Q using zero padding.
Center the image using fp(x,y) * (-1)^(x+y)
Compute the DFT F(u,v) of the image from step 3.
Construct a real symmetric filter transfer function H(u,v) of size P x Q with center at (P/2, Q/2).
Form the product G(u,v)=G(u,v)*H(u,v) using element wise multiplication.
Obtain the filtered image by computing the IDFT of G(u,v), and decenter the image. gp(x,y) = (real[IDFT{G(u,v)}])*(-1)^(x+y)
Obtain the final filtered result g(x,y) of the same size as the input image by extracting the M x N region from the top, left quadrant of gp(x,y).
I have written the following code to filter my image and accomplish the steps above (thanks to lots of helpful answers on this website).
Question:
In my figure F_uv_dftImage I should see a periodic frequency spectrum. I can but I need to zoom in really close currently to see a tiny image. In the book im using they show this a lot more clearly. Am I using the wrong data types throughout my code (double) to get the results? Or am I just plotting these graphs in the wrong way to display the data? Any input would be great!
If you want to see my code please just message me directly.
Aleksander Banburhttps://fr.mathworks.com/matlabcentral/profile/authors/4587522-aleksander-banburtag:fr.mathworks.com,2005:Question/5141562020-03-30T23:34:03Z2020-03-31T00:06:06ZClassification learner - Confusion matrixI am trying to interpritate the results of confusion matrix (Classification Learner Toolbox) but can not find True Negative rate (TN) and false positive values (FP). I am wondering if FP is related to the 'False Discovery Rates' and 'Positive Predictive Vsalues' could be TN values?EKhttps://fr.mathworks.com/matlabcentral/profile/authors/4362487-ektag:fr.mathworks.com,2005:Question/5138732020-03-30T06:28:27Z2020-03-31T00:02:27ZAssigning probability to each row of a matrix (observation); and creating exogenous demand sample based on observed matrixI have an m by n matrix - would like to assign probability to each row of the matrix.
Each row now has a probability associated with it and can be treated as one observation. I need to draw N (the sample size) number of these rows based on their assigned probability. Not sure how to do it. (referred to a link created in 2012 but don't understand the solution)
SethChttps://fr.mathworks.com/matlabcentral/profile/authors/17986865-sethctag:fr.mathworks.com,2005:Question/4518742019-03-23T13:11:00Z2020-03-31T00:00:09Zhow to download data from website?Dear all,
I am trying to download data from the following website
https://oceandata.sci.gsfc.nasa.gov/MODIS-Aqua/Mapped/Daily/4km/sst/2019/
my problem is I can not get the files, meaning only the html been located to my computer. (below what I used to locat the link into my machine)
url='https://oceandata.sci.gsfc.nasa.gov/MODIS-Aqua/Mapped/Daily/4km/sst/2019/'
filename='A2019.nc'
outfilename=websave(filename,url)
what I need is getting the files separtly and read them.
Thanks for the help.
Lola SEhttps://fr.mathworks.com/matlabcentral/profile/authors/6648456-lola-setag:fr.mathworks.com,2005:Question/5141632020-03-30T23:56:00Z2020-03-30T23:56:00ZOverlaying two contour plots on same axis
I am trying to plots two contours on top of each other
Code is below, cannot work out why it is not working.
figure(1)
[c1,h1]=contourf(long1,lat1,squeeze(asal(:,:,36))',[34.6:0.01:34.9],'LineColor','none')
cmocean('balance')
colorbar
hold on
[c2,h2]=contour(long1,lat1,squeeze(pot_dens(:,:,36))',[26.80:.01:27.0],'k--')
clabel(c2,h2)
I have attached the different plots seperately, and the combined result.
I want just the sal plot as is, with the potential density contours overlaid
Thanks in advanceJames Wyatthttps://fr.mathworks.com/matlabcentral/profile/authors/9810983-james-wyatt