https://se.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2019-10-20T19:26:07Ztag:se.mathworks.com,2005:Question/4864502019-10-20T19:10:03Z2019-10-20T19:23:40ZGenerate a random matrix without repeating any value in row and column. How can I generate a random matrix without repeating any value in row and column. form "randi" function.
If we generate a matrix.
then the answer may be like this
randi(4,4)
ans =
4 2 3 1
3 4 1 2
1 3 2 4
2 1 4 3
this is just for example not generated matrix.
I have used the "unique" function. by this i can control the repeatition in row only.Ashuftah Shigrihttps://se.mathworks.com/matlabcentral/profile/authors/12449249-ashuftah-shigritag:se.mathworks.com,2005:Question/4864522019-10-20T19:23:25Z2019-10-20T19:23:25ZLocate any decimal value inside a matrix?Im tryining to find any values that are not whole numbers inside a 3x3 matrix x=[1 2.5 4;5 3 3.2;4 9 2]
I want to use the for loop to check every value inside the matrix.
This is my code so far.
w=mod(x,1)~=0; %checking for whole numbers in the matrix
d=x(w) %this are the values that failed the whole number test
[r,c]=find(w); %location of those values
How would i used the for loop?
Jose Grimaldohttps://se.mathworks.com/matlabcentral/profile/authors/15984123-jose-grimaldotag:se.mathworks.com,2005:Question/4864452019-10-20T18:42:25Z2019-10-20T19:20:59ZHi there. i want to know that how can i change my MATLAB scale from scientific notation to mannual? I have my values on Y axis as [668.85 2548 5733 10192 15925 22932]Aiman Masoodhttps://se.mathworks.com/matlabcentral/profile/authors/16350630-aiman-masoodtag:se.mathworks.com,2005:Question/4864472019-10-20T19:00:28Z2019-10-20T19:20:42ZHelp writing a program than calculates the area of a series of annuliFor an annulus write a program to find the area, perimeter (or circumference) for a range of parametric values given by the user and plot the corresponding shapes in the range given. User needs to identify lower and upper values of each parameter. The identified range for the parameters should be then divided into 10 monotonic steps inside your program. Accordingly, you need to calculate the values and plot the shapes corresponding to all 10 values in the range identified by the user. The program should plot the geometries in the first quadrantAStarhttps://se.mathworks.com/matlabcentral/profile/authors/16242449-astartag:se.mathworks.com,2005:Question/4864512019-10-20T19:13:34Z2019-10-20T19:16:34Zhow to put/get a matrix from arrayhi guys. i have 4 matrixes. i put them in a array. now i want to get the nth matrix from this array. i used B(1) (forexample) but it gives me [2×2 double].
plz help me. how i can get the nth matrix ?
s0=[1 0;0 1];
sx=[0 1;1 0];
sy=[0 -1i;1i 0];
sz=[1 0;0 -1];
B={s0 sx sy sz};reza hamzehhttps://se.mathworks.com/matlabcentral/profile/authors/16618054-reza-hamzehtag:se.mathworks.com,2005:Question/4864422019-10-20T18:18:23Z2019-10-20T19:15:19ZCreate a new vector with even numbers first.I have a vector = [20 21 22 23 24 25 26 27 28 29]
My task is to create a new vector from the first, with the even numbers first and then the odd numbers = [20 22 24 26 28 21 23 25 26 27 28 29]
Last I have to make it the Dame way but Vice versa.
Michael Noakhttps://se.mathworks.com/matlabcentral/profile/authors/16618077-michael-noaktag:se.mathworks.com,2005:Question/4859922019-10-17T20:39:41Z2019-10-20T19:11:45ZIncorrect dynamic torques.Running the following code outputs incorrect torques. The static torques come out to be correct but the dynamic torques are incorrect. This is because link 6 has no length and mass but it still has some torque. Have I inputted incorrect values of center of mass or moment of inertia? center of mass and moment of inertia were copied from the solidworks file. Solidworks axes are different but we switched the values accordingly. However, the output is still wrong. Anybody help?
robot=robotics.RigidBodyTree;
body1=robotics.RigidBody('body1');
body1.Mass=0;
body1.CenterOfMass=[0 0 0];
jnt1=robotics.Joint('jnt1','revolute');
tform=trvec2tform([0 0 0]);
setFixedTransform(jnt1,tform);
body1.Joint=jnt1;
addBody(robot,body1,'base')
body2=robotics.RigidBody('b2');
body2.Mass=0.085;
body2.CenterOfMass=[0 0 0.03];
body2.Inertia=[1180 655.2 1129.6 0 0 0]/100000000;
jnt2=robotics.Joint('jnt2','revolute');
jnt2.JointAxis=[0 1 0];
tform=trvec2tform([0 0 0.06]);
setFixedTransform(jnt2,tform);
body2.Joint=jnt2;
body3=robotics.RigidBody('b3');
body3.Mass=0.0829;
body3.CenterOfMass=[0.0603 0.0023 -0.0099];
body3.Inertia=[626.6 320.8 396 0 0 0]/100000000;
jnt3=robotics.Joint('jnt3','revolute');
jnt3.JointAxis=[0 1 0];
tform=trvec2tform([0.07 0 0]);
setFixedTransform(jnt3,tform);
body3.Joint=jnt3;
body4=robotics.RigidBody('b4');
body4.Mass=0.066;
body4.CenterOfMass=[0.0633 -0.0063 -0.0025];
body4.Inertia=[678.3 678.3 734 0 0 0]/100000000;
jnt4=robotics.Joint('jnt4','revolute');
jnt4.JointAxis=[1 0 0];
tform=trvec2tform([0.1 0 0]);
setFixedTransform(jnt4,tform);
body4.Joint=jnt4;
body5=robotics.RigidBody('b5');
body5.Mass=0.02766;
body5.CenterOfMass=[0.04/2 0 0];
body5.Inertia=[412.5 178.1 309.8 0 0 0]/100000000;
jnt5=robotics.Joint('jnt5','revolute');
jnt5.JointAxis=[0 1 0];
tform=trvec2tform([0.04 0 0]);
setFixedTransform(jnt5,tform);
body5.Joint=jnt5;
body6=robotics.RigidBody('b6');
body6.Mass=0.0620;
body6.CenterOfMass=[0.11/2 0 0];
body6.Inertia=[1539 263.2 1509 0 0 0]/100000000;
jnt6=robotics.Joint('jnt6','revolute');
jnt6.JointAxis=[1 0 0];
tform=trvec2tform([0.11 0 0]);
setFixedTransform(jnt6,tform);
body6.Joint=jnt6;
addBody(robot,body2,'body1')
addBody(robot,body3,'b2')
addBody(robot,body4,'b3')
addBody(robot,body5,'b4')
addBody(robot,body6,'b5')
robot.DataFormat='row';
robot.Gravity=[0 0 -9.81];
config=homeConfiguration(robot);
% fext = externalForce(robot,'b',wrench);
inverseDynamics(robot,config,[0.1 0.1 0.1 0.1 0.1 0.1],[0.05 0.05 0.05 0.05 0.05 0.05])Muhammad Aleemhttps://se.mathworks.com/matlabcentral/profile/authors/15209884-muhammad-aleemtag:se.mathworks.com,2005:Question/4852652019-10-14T16:56:47Z2019-10-20T19:11:29Z MATLAB Design a S-Box for DES (4x4) MATLAB Design a S-Box for DES (4x4) and verify that for each input it holds Strict Avalanche Criterion (Change in single bit at input inverts half output bits). Ashuftah Shigrihttps://se.mathworks.com/matlabcentral/profile/authors/12449249-ashuftah-shigritag:se.mathworks.com,2005:Question/4864252019-10-20T17:08:30Z2019-10-20T19:11:14ZConnecting dots with straight line in a loop.Hi all,
I have a question regarding connecting the dots.
Suppose I have the following sample data points:
I have a while-loop that identifies the first, second, and fourth points in the figure.
I know their index numbers and their (x,y) values.
Pictorially, I would like to connect with a straight line, the aforementioned points.
What is the best way of doing this?
My gut feeling is to input the "draw" code within the while-loop I have so each time I obtain the index of the next point I want to connect, I simply connect to that pictorially. But how to go about this?
Thanks in advance!
Tatte Berkleehttps://se.mathworks.com/matlabcentral/profile/authors/7634033-tatte-berkleetag:se.mathworks.com,2005:Question/4864302019-10-20T17:15:56Z2019-10-20T19:05:19ZHow do I plot the curve x^2+y^2=1+2.5sin(xy) in polar coordinates in mathlab?From what I know, the x-coordinates can be written as r.*cos(t) and y-coordinates as r.*sin(t). However, when it comes to plotting, I have no idea of how I shall do. I've tried to plot this function in plotting softwares, such as geogebra and know what it is supposed to look like.
My current script looks like this
As you can see, I'm still hesistant of wheter I should convert the polar coordinates to cartesian, or plot based on the angle and the curve.Ibrahim Tahahttps://se.mathworks.com/matlabcentral/profile/authors/16189140-ibrahim-tahatag:se.mathworks.com,2005:Question/3986682018-04-30T04:00:00Z2019-10-20T19:03:30ZHow do I connect to Thomson Reuters Eikon in MATLAB R2017b?How do I connect to Thomson Reuters Eikon in MATLAB R2017b?
I am interested in establishing connections to Thomson Reuters Datastream API.
MathWorks Support Teamhttps://se.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:se.mathworks.com,2005:Question/4864492019-10-20T19:02:42Z2019-10-20T19:02:42ZPlease help me to using genetic algorithmI write this code but I want to solve this problem with 'ga' not with 'intlinprog' solver!
Can anyone guide me?
<</matlabcentral/answers/uploaded_files/243672/1.png>>
<</matlabcentral/answers/uploaded_files/243673/2.png>>
<</matlabcentral/answers/uploaded_files/243674/3.png>>
S AsZhttps://se.mathworks.com/matlabcentral/profile/authors/16431168-s-asztag:se.mathworks.com,2005:Question/4864222019-10-20T16:54:37Z2019-10-20T19:01:23Zsignal processing (segmentation )After i segment a signal to 5 or 7 segments ...
how i can make these segments ( segments with different length) a one signal ??
eman mohammadhttps://se.mathworks.com/matlabcentral/profile/authors/16345999-eman-mohammadtag:se.mathworks.com,2005:Question/4857442019-10-16T19:25:24Z2019-10-20T18:53:27ZLow Pass filter not workingI audioread() a signal and tried to apply low-pass filtering but it does not seem to have any change at all. The signal is a recording of lung sound and I wish to filter out the noise component.
[y,Fs] = audioread('mysound.wav')
Fs = 44100; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency
Fco = 70; % Passband (Cutoff) Frequency
Fsb = 100; % Stopband Frequency
Rp = 1; % Passband Ripple (dB)
Rs = 10; % Stopband Ripple (dB)
[n,Wn] = buttord(Fco/Fn, Fsb/Fn, Rp, Rs); % Filter Order & Wco
[b,a] = butter(n,Wn); % Lowpass Is Default Design
[sos,g] = tf2sos(b,a);
filt_sig = filtfilt(sos,g,y)
Neither the plot(), FFT() or soundsc() shows anything different. I've tried cheby filters as well. Am I doing anything wrong? Thanks for the help.Yipp Chun Munnhttps://se.mathworks.com/matlabcentral/profile/authors/14232156-yipp-chun-munntag:se.mathworks.com,2005:Question/4864462019-10-20T18:49:31Z2019-10-20T18:49:31ZError: Error using load Unknown text on line number 1 of ASCII file cats.csv "Sex".Hello everyone,
I am trying to load a csv. document on to Matlab but I'm struggling. MY csv file has three titles "Sex, Bwt and Hwt". The error I am getting is as below:
Error using load
Unknown text on line number 1 of ASCII file cats.csv
"Sex".
I tried to use readmatrix as well, but then I can't plot. I'm new to MATLAB and I have no idea what I am doing. Please help.
Best RegardsZakhele Gamedehttps://se.mathworks.com/matlabcentral/profile/authors/16627572-zakhele-gamedetag:se.mathworks.com,2005:Question/4864442019-10-20T18:40:02Z2019-10-20T18:44:52Zvectors must be at the same length errorHi, im trying to plot this fuction but im getting th 'vectors must be at the same length' error, Can anybody help to find a solution?
t=-10:10;
x = heaviside(t+2)-heaviside(t-2);
plot(t,x);
y = awgn(x,21,'measured');
plot(t,[x y]);
legend('Original Signal','Signal with AWGN');fatemeh phttps://se.mathworks.com/matlabcentral/profile/authors/12562759-fatemeh-ptag:se.mathworks.com,2005:Question/4863192019-10-19T19:38:08Z2019-10-20T18:38:38ZUsing same figure properties (e.g. current axes) onto new onesI was wondering how am I able with a short script or few lines of code to copy some figure's properties and be able to use them on new ones. There are few similar questions around the Central but they seem either to be outdated or too complicated. Any suggestions would be much appreciated!Vasileios Leivadashttps://se.mathworks.com/matlabcentral/profile/authors/10140916-vasileios-leivadastag:se.mathworks.com,2005:Question/4862952019-10-19T15:15:41Z2019-10-20T18:30:51ZCreate a table in MatLab with specific data in different spreadsheets in one Excel File.Hello together,
I have an Excel File with 10 spreadsheets and I want to import data (always range: A2:K7) from every spreadsheet into a table in MatLab. I want to create a Loop so that the data is displayed beneath one another.
Thank you for your support!Leon Wohlgemuthhttps://se.mathworks.com/matlabcentral/profile/authors/16069548-leon-wohlgemuthtag:se.mathworks.com,2005:Question/4863262019-10-19T20:35:06Z2019-10-20T18:30:24Zhow to find the effective bandwidth of a signal (chirp linear modulated signal) hello , is the following code correct? if not please tell me the right one
Fs =1000; % Sampling frequency
T = 1/Fs;
L=1000; % length of the signal
t = (0:L-1)*T; % Time vector
x=chirp(t,10,L-1,100,'linear');
f=fft(x);
m=abs(f);
F=(0:L-1)*T;
e=trapz(m.^2);
b=trapz((F.^2).*m.^2);
Beff=(b/e).^0.5
mavi gulhttps://se.mathworks.com/matlabcentral/profile/authors/16621006-mavi-gultag:se.mathworks.com,2005:Question/4864212019-10-20T16:47:49Z2019-10-20T18:22:04ZChange color outside region of polyshapeI have gridded data between -40°S 0°S to 10°E to 45°E. I have manged to plot this data and add the borders of the countries over it. How can I mask the data that is plotted over the oceans. I only want to see the data over the land.
David du Preezhttps://se.mathworks.com/matlabcentral/profile/authors/7651225-david-du-preeztag:se.mathworks.com,2005:Question/4864432019-10-20T18:20:24Z2019-10-20T18:20:24ZHow do I mark one observation in multiple scatterplots (created with gplotmatrix)?Hi,
I want to mark one observation in multiple scatterplots created with gplotmatrix. My workaround would be to get the individual subplots and add a marker by plotting a red circle around the observation. My code example:
load fisheriris
[h,~,~] = gplotmatrix(meas(1:100,:),[],species(1:100,:),[],[],[],[],[],{'Sepal Length','Sepal Width','Petal Length','Petal Width'})
I can get the subplots with e.g. h(2,1,1), but I don't know how to add a plot to them. The hold on command doesn't seem to work.
Are there maybe smarter ways of marking one specific observation in gplotmatrix?
Thanks in advance!Mathies Wedlerhttps://se.mathworks.com/matlabcentral/profile/authors/4236909-mathies-wedlertag:se.mathworks.com,2005:Question/4864062019-10-20T14:49:24Z2019-10-20T18:18:38Zreading large text files into matrixim trying to read a text file containing matrix
A = readmatrix('output1.txt','Whitespace',' []'); when i execute it
its displaying
NaN NaN
NaN NaN
NaN NaN
NaN NaN
here output1.txt file contains data in the given manner
[[0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 1 0 1]
[0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0]]-50*50
what else changes can i make .
BTW it worked fine when matrix size is low i.e when every row of matrix is displayed in single line but as size of matrix increases single row is being displayed in multiple lines thats when problem arised.
i have attached the text file.
can some one modfy this A = readmatrix('output1.txt','Whitespace',' []');
so it can read matrix from the file irrespective of how large it is.Nitish Reddy Kotkurhttps://se.mathworks.com/matlabcentral/profile/authors/16284860-nitish-reddy-kotkurtag:se.mathworks.com,2005:Question/4864122019-10-20T15:29:16Z2019-10-20T18:18:29ZI'm trying to write a program that types out a line with n integers starting with n0 , separated by commas and spaces. It needs to use a forloop and should turn out like this n=10 n0=5 --> 5, 6, 7, 8, 9, 10, 11, 12, 13, 14. This is what I have so far%Countem
%Program that types out a line with n integers starting with n0
%Author Dmitri
clear;clc
%% set parameters
n=10
%% calculate
for n0=5:n
f(n0)=n0
end
%% Display results
Custode Dmitri Francescohttps://se.mathworks.com/matlabcentral/profile/authors/15903617-custode-dmitri-francescotag:se.mathworks.com,2005:Question/4864412019-10-20T18:12:06Z2019-10-20T19:26:07ZGive Matlab commands to plot, on the same figure, the two functions: (5) a. f=3t2 +2t-0.5 b. g=2t cos(t) where the variable t varies from 0 to 10 with step 0.5. Draw the function f in blue 0 and the function g in red *. Give title to your graph as yoGive Matlab commands to plot, on the same figure, the two functions: (5) a. f=3t2 +2t-0.5 b. g=2t cos(t) where the variable t varies from 0 to 10 with step 0.5. Draw the function f in blue 0 and the function g in red *. Give title to your graph as your registration number and label the axes.Raviteja Darahttps://se.mathworks.com/matlabcentral/profile/authors/15926926-raviteja-daratag:se.mathworks.com,2005:Question/4670552019-06-14T08:45:35Z2019-10-20T18:02:02ZHow to find the transformation matrix for a plat knowing the old and new coordinates of 3 points on it ?Hi All
How do I define the transformation matrix of a plate that moves in space , knowing the old and new coordinates of 3 points on the plate ? (assume a circular plate and reference coordinate system in the center of the plate )farzadhttps://se.mathworks.com/matlabcentral/profile/authors/2231846-farzadtag:se.mathworks.com,2005:Question/4734222019-07-25T10:12:03Z2019-10-20T18:01:54ZAbnormal termination: Access violation !------------------------------------------------------------------------
Access violation detected at Thu Jul 25 12:06:57 2019
------------------------------------------------------------------------
Configuration:
Crash Decoding : Disabled - No sandbox or build area path
Crash Mode : continue (default)
Current Graphics Driver: NVIDIA Corporation Quadro P1000/PCIe/SSE2 Version 4.6.0 NVIDIA 391.48
Default Encoding : windows-1252
Deployed : false
Graphics card 1 : NVIDIA ( 0x10de ) NVIDIA Quadro P1000 Version 23.21.13.9148 (2018-4-17)
Graphics card 2 : Intel Corporation ( 0x8086 ) Intel(R) UHD Graphics 630 Version 24.20.100.6286 (2018-8-15)
Host Name : VSL9GNMW
MATLAB Architecture : win64
MATLAB Entitlement ID: 3778498
MATLAB Root : C:\tools\MATLAB\2017b
MATLAB Version : 9.3.0.867777 (R2017b) Update 7
OpenGL : hardware
Operating System : Microsoft Windows 10 Enterprise
Processor ID : x86 Family 6 Model 158 Stepping 10, GenuineIntel
Virtual Machine : Java 1.8.0_144-b01 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
Window System : Version 10.0 (Build 17763)
Fault Count: 1
Abnormal termination:
Access violation
Register State (from fault):
RAX = 000000003f779d50 RBX = 00000001081eeb50
RCX = 000000020c27f9d0 RDX = 000000020b66cc75
RSP = 00000000043fa5d0 RBP = 00000000043fa5d0
RSI = 0000000115ccf870 RDI = 000000020c27f9d0
R8 = 0000000000000000 R9 = 0000000000000000
R10 = 000000000b6cb7c0 R11 = 00000000043fa900
R12 = 0000000000000000 R13 = 000000003ed72df0
R14 = 00000001ba98f5d0 R15 = 0000000000000000
RIP = 000000000b8f175a EFL = 00010246
CS = 0033 FS = 0053 GS = 002b
Stack Trace (from fault):
[ 0] 0x000000000b8f175a D:\Proj\Proj_CLC_R17b\Model\CLC_sf.mexw64+00005978
[ 1] 0x000000003dbf9c01 bin\win64\libmwsimulink.dll+18783233 slSetStateflowChartStateAccessInterface+00206321
[ 2] 0x000000003dbccedb bin\win64\libmwsimulink.dll+18599643 slSetStateflowChartStateAccessInterface+00022731
[ 3] 0x000000003d9bda2c bin\win64\libmwsimulink.dll+16439852 BlockSetLocation+00008668
[ 4] 0x000000003d2679ed bin\win64\libmwsimulink.dll+08747501 mdlref_simtarget::slmrAccelRunBlockSystemReset+00204845
[ 5] 0x000000003d35c10e bin\win64\libmwsimulink.dll+09748750 sl::InterfaceDisplayJob::createUnitsUpdateJob+00176174
[ 6] 0x000000003dc85c3d bin\win64\libmwsimulink.dll+19356733 SLGlue::PortSignalGenerator::isEmpty+00370605
[ 7] 0x000000003dc85c07 bin\win64\libmwsimulink.dll+19356679 SLGlue::PortSignalGenerator::isEmpty+00370551
[ 8] 0x000000015b55a33b bin\win64\libmwslexec_runtime.dll+00369467 slexec::runtime::sim::ExecutionHelper::serialize+00056395
[ 9] 0x000000003dc43f93 bin\win64\libmwsimulink.dll+19087251 SLGlue::PortSignalGenerator::isEmpty+00101123
[ 10] 0x000000003dc43ff2 bin\win64\libmwsimulink.dll+19087346 SLGlue::PortSignalGenerator::isEmpty+00101218
[ 11] 0x000000003dc341bd bin\win64\libmwsimulink.dll+19022269 SLGlue::PortSignalGenerator::isEmpty+00036141
[ 12] 0x000000003dc33dd2 bin\win64\libmwsimulink.dll+19021266 SLGlue::PortSignalGenerator::isEmpty+00035138
[ 13] 0x000000003dc2e59c bin\win64\libmwsimulink.dll+18998684 SLGlue::PortSignalGenerator::isEmpty+00012556
[ 14] 0x000000003dc2692a bin\win64\libmwsimulink.dll+18966826 slstSetOutputPortRateID+00075242
[ 15] 0x000000003dc2133a bin\win64\libmwsimulink.dll+18944826 slstSetOutputPortRateID+00053242
[ 16] 0x000000003dc269ec bin\win64\libmwsimulink.dll+18967020 slstSetOutputPortRateID+00075436
[ 17] 0x000000003dc1e97f bin\win64\libmwsimulink.dll+18934143 slstSetOutputPortRateID+00042559
[ 18] 0x000000003dc212f6 bin\win64\libmwsimulink.dll+18944758 slstSetOutputPortRateID+00053174
[ 19] 0x000000003dc1f813 bin\win64\libmwsimulink.dll+18937875 slstSetOutputPortRateID+00046291
[ 20] 0x000000003dc27f76 bin\win64\libmwsimulink.dll+18972534 slstSetOutputPortRateID+00080950
[ 21] 0x00000000fd0080f7 bin\win64\iqm.dll+00491767 iqm::PackagedTaskPlugin::PackagedTaskPlugin+00000759
[ 22] 0x00000000fd0088bf bin\win64\iqm.dll+00493759 iqm::PackagedTaskPlugin::execute+00000879
[ 23] 0x00000000fd00817d bin\win64\iqm.dll+00491901 iqm::PackagedTaskPlugin::PackagedTaskPlugin+00000893
[ 24] 0x00000000fd008708 bin\win64\iqm.dll+00493320 iqm::PackagedTaskPlugin::execute+00000440
[ 25] 0x0000000015545651 bin\win64\mcr.dll+00349777 OnlineLicenseManagementLauncher::~OnlineLicenseManagementLauncher+00010049
[ 26] 0x00000000fcfdbd3a bin\win64\iqm.dll+00310586 iqm::Iqm::setupIqmFcnPtrs+00079802
[ 27] 0x00000000fcfdbc06 bin\win64\iqm.dll+00310278 iqm::Iqm::setupIqmFcnPtrs+00079494
[ 28] 0x00000000fcfbeb65 bin\win64\iqm.dll+00191333 iqm::Iqm::deliver+00001397
[ 29] 0x00000000fb5fd3c3 bin\win64\libmwbridge.dll+00054211 ioReadLine+00000547
[ 30] 0x00000000fb5fd262 bin\win64\libmwbridge.dll+00053858 ioReadLine+00000194
[ 31] 0x00000000fb60d7de bin\win64\libmwbridge.dll+00120798 mnDebugPrompt+00001966
[ 32] 0x00000000fb60d170 bin\win64\libmwbridge.dll+00119152 mnDebugPrompt+00000320
[ 33] 0x00000000fb60db63 bin\win64\libmwbridge.dll+00121699 mnParser+00000547
[ 34] 0x000000001552bdb1 bin\win64\mcr.dll+00245169 mcr::runtime::setInterpreterThreadSingletonToCurrent+00029793
[ 35] 0x000000001552ace5 bin\win64\mcr.dll+00240869 mcr::runtime::setInterpreterThreadSingletonToCurrent+00025493
[ 36] 0x000000001552ad53 bin\win64\mcr.dll+00240979 mcr::runtime::setInterpreterThreadSingletonToCurrent+00025603
[ 37] 0x000000001552b6e1 bin\win64\mcr.dll+00243425 mcr::runtime::setInterpreterThreadSingletonToCurrent+00028049
[ 38] 0x00000000fd02cc77 bin\win64\iqm.dll+00642167 iqm::UserEvalPlugin::pre+00028951
[ 39] 0x00000000fd039cfc bin\win64\iqm.dll+00695548 iqm::UserEvalPlugin::pre+00082332
[ 40] 0x00000000fd02737f bin\win64\iqm.dll+00619391 iqm::UserEvalPlugin::pre+00006175
[ 41] 0x00000000fd02cc16 bin\win64\iqm.dll+00642070 iqm::UserEvalPlugin::pre+00028854
[ 42] 0x00000000fd027863 bin\win64\iqm.dll+00620643 iqm::UserEvalPlugin::pre+00007427
[ 43] 0x00000000fd03c8b6 bin\win64\iqm.dll+00706742 iqm::UserEvalPlugin::pre+00093526
[ 44] 0x00000000fd0080f7 bin\win64\iqm.dll+00491767 iqm::PackagedTaskPlugin::PackagedTaskPlugin+00000759
[ 45] 0x00000000fd0088bf bin\win64\iqm.dll+00493759 iqm::PackagedTaskPlugin::execute+00000879
[ 46] 0x00000000fd00817d bin\win64\iqm.dll+00491901 iqm::PackagedTaskPlugin::PackagedTaskPlugin+00000893
[ 47] 0x00000000fd008708 bin\win64\iqm.dll+00493320 iqm::PackagedTaskPlugin::execute+00000440
[ 48] 0x00000000fcfdbd3a bin\win64\iqm.dll+00310586 iqm::Iqm::setupIqmFcnPtrs+00079802
[ 49] 0x00000000fcfdbc06 bin\win64\iqm.dll+00310278 iqm::Iqm::setupIqmFcnPtrs+00079494
[ 50] 0x00000000fcfbf5be bin\win64\iqm.dll+00193982 iqm::Iqm::deliver+00004046
[ 51] 0x00000000fcfc0545 bin\win64\iqm.dll+00197957 iqm::Iqm::deliver+00008021
[ 52] 0x00000001001237c1 bin\win64\libmwservices.dll+01259457 services::system_events::PpeDispatchHook::dispatchOne+00021505
[ 53] 0x0000000100128663 bin\win64\libmwservices.dll+01279587 sysq::addProcessPendingEventsUnitTestHook+00002211
[ 54] 0x0000000100128850 bin\win64\libmwservices.dll+01280080 sysq::addProcessPendingEventsUnitTestHook+00002704
[ 55] 0x0000000100129c26 bin\win64\libmwservices.dll+01285158 sysq::getCondition+00003462
[ 56] 0x000000010012ac66 bin\win64\libmwservices.dll+01289318 svWS_ProcessPendingEvents+00000230
[ 57] 0x000000001552c244 bin\win64\mcr.dll+00246340 mcr::runtime::setInterpreterThreadSingletonToCurrent+00030964
[ 58] 0x000000001552c964 bin\win64\mcr.dll+00248164 mcr::runtime::setInterpreterThreadSingletonToCurrent+00032788
[ 59] 0x0000000015522762 bin\win64\mcr.dll+00206690 mcr_process_events+00008818
[ 60] 0x00000000154623c5 bin\win64\MVMLocal.dll+00271301 mvm_server::inproc::LocalFactory::terminate+00088005
[ 61] 0x00000000fa957669 bin\win64\mvm.dll+01209961 mvm::detail::initLocalMvmHack+00000569
[ 62] 0x00000000fa957e2b bin\win64\mvm.dll+01211947 mvm::detail::SessionImpl::privateSession+00000555
[ 63] 0x00000000fa958051 bin\win64\mvm.dll+01212497 mvm::detail::SessionImpl::privateSession+00001105
[ 64] 0x0000000140007833 bin\win64\MATLAB.exe+00030771
[ 65] 0x000000014000863f bin\win64\MATLAB.exe+00034367
[ 66] 0x00007fffcbe97974 C:\windows\System32\KERNEL32.DLL+00096628 BaseThreadInitThunk+00000020
[ 67] 0x00007fffcd24a271 C:\windows\SYSTEM32\ntdll.dll+00434801 RtlUserThreadStart+00000033
If this problem is reproducible, please submit a Service Request via:
http://www.mathworks.com/support/contact_us/
A technical support engineer might contact you with further information.
Thank you for your help.** This crash report has been saved to disk as C:\Users\uidv8026\AppData\Local\Temp\matlab_crash_dump.7028-1 **Isidore Botchakhttps://se.mathworks.com/matlabcentral/profile/authors/5609686-isidore-botchaktag:se.mathworks.com,2005:Question/4864402019-10-20T18:01:19Z2019-10-20T18:01:19Zsolving equation contains lambertw functionHi. I wanna solve this equation and i have Q* and G. W_0 is lambertw function. does anybody know how should i solve this? is it possible or i need more information?
i want a scalar for gamma_0.
kamran kianhttps://se.mathworks.com/matlabcentral/profile/authors/11232604-kamran-kiantag:se.mathworks.com,2005:Question/4864382019-10-20T17:58:27Z2019-10-20T17:58:27ZI am having problem in FFT functionHow to calculate and plot the DFT of 11616026 like x=[1 1 6 1 6 0 2 6] using FFT function ? any idea? ?Anmol Chauhanhttps://se.mathworks.com/matlabcentral/profile/authors/16626942-anmol-chauhantag:se.mathworks.com,2005:Question/4864262019-10-20T17:09:27Z2019-10-20T17:51:57ZHazy image equation implementation.I have an hazy image equation. When I am try to implement that equattion I only get a black image only.
This is my equation. How can I implement this equation in matlab correctly.Please help me.Silpa Khttps://se.mathworks.com/matlabcentral/profile/authors/15760628-silpa-ktag:se.mathworks.com,2005:Question/4864312019-10-20T17:19:04Z2019-10-20T17:39:28ZS-Function DocumentationHi,
In general mathworks has wonderful documentation. However, im struggling to find the information i need regarding how to use the level 2 s-function with the matlab syntax. For example, in the full sfun template there is a property of the block class called "OperatingPointCompliance" used in the setup method of the template: " block.OperatingPointCompliance = 'Default';". Where is the documentation on the class that this property is owned by? There is some info here on a related method.
Currently, these 2 pages have helped me with some of properties and methods of the class that is being used:
https://www.mathworks.com/help/simulink/slref/simulink.runtimeblock.html#f29-97412
https://www.mathworks.com/help/simulink/slref/simulink.msfcnruntimeblock.html#f29-99608
In the template, the level 2 s-function operates on a thing called "block" which appears to be a "Simulink.MSFcnRunTimeBlock" class with parent class "Simulink.RunTimeBlock"...based on the template, the block object (i.e. the level 2 s function block in simulink) is a "Simulink.MSFcnRunTimeBlock" and thus it inherits the properties and methods of its parent class? Are there any other derivative classes that the block has that i should know about when using the level 2 s-function?
Also, s-function template has a series of methods/functions documented here. Can you confirm or correct the following... the s-function is not dependent on this exact structure? For example, theres a method called "outputs", however if i wanted to combine this method with the "update" method, I could simply update the template as follows? Or create my own methods? Lastly, what is the order in which the registered methods of the script operate, is the RegBlockMethod actually calling the method?
block.RegBlockMethod('OutputsandUpdatesMethod", @OutputsUpdate);
function OutputsUpdate(block)
block.OutputPort(1).Data = block.Dwork(1).Data + block.InputPort(1).Data;
block.Dwork(1).Data = block.InputPort(1).Data;
%endfunction
Thanks in advance,
AndyAndrew Hunterhttps://se.mathworks.com/matlabcentral/profile/authors/4874293-andrew-huntertag:se.mathworks.com,2005:Question/4864352019-10-20T17:35:36Z2019-10-20T17:35:36ZEstimating the X and Y coordinates from optical flow methodHi, I am trying to detect moving objects to obatin their corresponding X and Y coordinates from a video. I was using 'opticFlow' algorithm for this process. I am unable to understand on how to extract the X and Y coordinates from the velocity field which the function 'estimateFlow' returns. Any help to solve this will be appreaciated.
flow = estimateFlow(opticFlow,frameGray);Hari krishnanhttps://se.mathworks.com/matlabcentral/profile/authors/13142902-hari-krishnantag:se.mathworks.com,2005:Question/4864342019-10-20T17:33:42Z2019-10-20T17:33:42ZSolving PDE for Hygromechanical Coupling with f coefficient as a function of previous PDE resultsHi everyone. I'm trying to solve a hygromechanical coupling using solvepde. The problem consists of a transient diffusion equation and a stationary 2D elasticity. The PDEs are:
for the diffusion where D is the coefficient of diffusion and C is the diffusing concentration and:
for the 2D elasticity where c is the elasticity tensor and alpha is the swelling-shrinkage coefficient. I solved the diffusion equation first by:
%% Geometry (a hollow cylinder)
D_e = 29; % in mm
D_i = 14; % in mm
r_e = D_e/2; % exterior radius
r_i = D_i/2; % interior radius
r1 = [1 0 0 r_e];
r2 = [1 0 0 r_i];
gdm = [r1; r2]';
g = decsg(gdm, 'R1-R2', ['R1'; 'R2']');
%% Solving diffusion
diffmodel = createpde(2);
geometryFromEdges(diffmodel,g);
mesh = generateMesh(diffmodel,'Hmax',1);
Dx = 0.55; Dy = 0.45; % Coefficient of diffusion for x and y direction
c_xy = [Dx; Dy];
specifyCoefficients(diffmodel,"a",0, ...
"c",c_xy, ...
"d",1, ...
"m",0, ...
"f",[0;0]);
applyBoundaryCondition(diffmodel,"dirichlet","Edge", ...
1:diffmodel.Geometry.NumEdges, ...
'u',[0.07;0.07]);
setInitialConditions(diffmodel,0.05);
tlist = 0:0.1:10;
resdiff = solvepde(diffmodel,tlist);
And then, I want f to represent the interpolated gradient of the diffusion solution (resdiff) times alpha (coefficient of swelling-shrinkage), I wrote a function in new file, myf.m, which contains:
function fout = myf(region,state,resdiff,teval)
coefRGx = 0.25; % swelling-shrinkage coef for x direction
coefRGy = 0.35; % swelling-shrinkage coef for y direction
xx = (region.x);
yy = (region.y);
[gradx,grady] = evaluateGradient(resdiff,xx,yy,1,teval); %teval because the previous solution is transient
fx = [gradx.*coefRGx;grady.*coefRGy];
fout = (fx);
end
then I describe the elasticity model by:
structmodel = createpde(2);
geometryFromEdges(structmodel,g);
meshstruct = generateMesh(structmodel,'Hmax',1);
E_p = 10e6;
mu_p = 0.40;
G = E_p/(2*(1+mu_p));
mu = 2*G*mu_p/(1-mu_p);
c_k = [2*G+mu; 0; G; 0; G; mu; 0; G; 0; 2*G+mu]; % elasticity tensor for 2D PDE
teval = 100; % evaluated time step
f_k = @(region,state) myf(region,state,resdiff,teval); % f-coefficient as a function
specifyCoefficients(structmodel,'m',0,'d',0,'a',0, ...
'c',c_k,'f',f_k);
applyBoundaryCondition(structmodel,"dirichlet","Edge", ...
5:8,'u',[0;0]); % the center part is held in place
setInitialConditions(structmodel,[0;0]);
Everything is alright until I tried to solve it:
structres = solvepde(structmodel);
where it returns me an error:
Error using formGlobalKF2D
Coefficient evaluation function,
"@(region,state)myf(region,state,resdiff,teval)", was
requested to calculate coefficients at 1500 locations so
should have returned a matrix with 1500 columns. Instead it
returned a matrix with 1 columns.
I was a bit surprised, but I thought it was just a problem of vector size, so I transposed the fout in my myf.m file, essentially editing it into:
function fout = myf(region,state,resdiff,teval)
coefRGx = 0.25; % swelling-shrinkage coef for x direction
coefRGy = 0.35; % swelling-shrinkage coef for y direction
xx = (region.x);
yy = (region.y);
[gradx,grady] = evaluateGradient(resdiff,xx,yy,1,teval); %teval because the previous solution is transient
fx = [gradx.*coefRGx;grady.*coefRGy];
fout = (fx).'; % transposed
end
but it gave me another error:
Error using formGlobalKF2D
Coefficient evaluation function,
"@(region,state)myf(region,state,resdiff,teval)", was
requested to calculate coefficients at 1 locations so should
have returned a matrix with 1 columns. Instead it returned a
matrix with 2 columns.
So I was lost here. Could you tell me where I did wrong?
Thank you in advance,
AhmadAhmadhttps://se.mathworks.com/matlabcentral/profile/authors/13617490-ahmadtag:se.mathworks.com,2005:Question/3801552018-02-01T10:05:26Z2019-10-20T17:33:24ZFaster R-CNN image input size & validationHi there,
I'm trying to train Faster R-CNN on my own dataset. My images are 440x440x3 and the objects that I'm trying to detect are fairly small (16x16x3).
I based my code on this example (https://uk.mathworks.com/help/vision/examples/object-detection-using-faster-r-cnn-deep-learning.html). I don't really understand why the image input layer takes images of a size which is much smaller than the original image (in the example the input is 32x32x3 while the whole image is about 200x200x3). It just seems a bit different than in the original paper by Girshick (https://arxiv.org/abs/1506.01497) where we pass the whole image through VGG16 first and then we extract the proposals from the created set of feature maps.
The explanation in the documentation is not very clear about how the Faster R-CNN (RPN in this sense) finds those smaller patches. Other implementations that I looked at (Caffe, TensorFlow) pass the whole image through VGG16 (or ZF) which has the same input size of the whole image but MATLAB documentation says:
"Start with the imageInputLayer function, which defines the type and size of the input layer. For classification tasks, the input size is typically the size of the training images. For detection tasks, the CNN needs to analyze smaller sections of the image, so the input size must be similar in size to the smallest object in the data set. In this data set all the objects are larger than [16 16], so select an input size of [32 32]. This input size is a balance between processing time and the amount of spatial detail the CNN needs to resolve."
I also looked at the following entry on MATLAB Answers (https://uk.mathworks.com/matlabcentral/answers/332757-faster-rcnn-code-in-matlab?s_tid=answers_rc1-1_p1_MLT) but I still don't understand how the RPN finds those smaller 32x32x3 regions (as in the example) without passing the whole image through the network. Could someone give some more insight into what's going on with the RPN in this case if the ImageInputLayer takes images of size 32x32x3 instead of the size of the original image?
----------------------
And just a quick question about using the validation while training fasterRCNNObjectDetector. The documentation says (https://uk.mathworks.com/help/vision/ref/trainfasterrcnnobjectdetector.html#inputarg_options):
"trainFasterRCNNObjectDetector does not support these training options:
- The ExecutionEnvironment values: 'multi-gpu' or 'parallel'
- The Plots value: 'training-progress'
- The ValidationData, ValidationFrequency, or ValidationPatience options"
Is there any way to assess when our network is overfitting without using the validation set? Karol Stanskihttps://se.mathworks.com/matlabcentral/profile/authors/10512436-karol-stanskitag:se.mathworks.com,2005:Question/4864332019-10-20T17:33:12Z2019-10-20T17:33:12ZUsing Simulink to observe music output spectrum
I need some help setting this up in the Simulink function in Matlab. I need to see the correct way to set this up.
In this section, you are importing music file in Simulink model.
Follow the following steps.
Create a new model.
From DSP system toolbox sources, drag from multimedia file into your model. Double click to get properties of it. Click the browse button to locate the music file you download into your workspace. You will see complete file path automatically set in to file name box.
From sinks, bought spectrum analyzer and to Audio device (Speaker symbol) into your model.
Connect multimedia block output to audio device and spectrum analyzer.
Run the model and observe your music output spectrum.
Peak frequencies (List four frequencies) in your music are concentrated at:________________________________ Khz
Take up-sample block (DSP system toolbox > signal operations >Up-sample) to you model.
Insert, up-sample block in between input and output. Double click and load up-sampling factor to 4. Observe up-sampled output audio and magnitude spectrum.
Nathan Jaquahttps://se.mathworks.com/matlabcentral/profile/authors/16087556-nathan-jaquatag:se.mathworks.com,2005:Question/4864322019-10-20T17:28:40Z2019-10-20T17:28:40ZMatlab doesn't open (though installed and activated)I installed and activated Matlab, but it will not open on my mac. It pops up on the dashboard for a split second and then disappears, and never shows up (nor does it prompt me to reenter license information or anything like that). I have tried deleting MATLAB files from my library directory and that does not seem to solve the problem.Claire Zarakashttps://se.mathworks.com/matlabcentral/profile/authors/16405048-claire-zarakastag:se.mathworks.com,2005:Question/4864292019-10-20T17:13:46Z2019-10-20T17:28:39ZTo generate following sequenceTo generate using stem function -
y(n) = 5 * e^cos(pi*n/3) * u(n-3)Anmol Chauhanhttps://se.mathworks.com/matlabcentral/profile/authors/16626942-anmol-chauhantag:se.mathworks.com,2005:Question/4864282019-10-20T17:12:39Z2019-10-20T17:28:29ZHow to save vector from loop?Hi,
i'm solving a cubic equation using roots command, i need only real solution not imaginary. I need to solve this equation for range of 1 to 150, and individual solutions save as a vector. I have a script that save only last solution. Could you please help me? Thanks a lot.
for v=0:150
x=roots([2*ro*A 0 2*ro*A*(2*v+v^2) -P]);
x = x(imag(x)==0);
endcad10https://se.mathworks.com/matlabcentral/profile/authors/15435832-cad10tag:se.mathworks.com,2005:Question/4864172019-10-20T16:30:45Z2019-10-20T17:26:17ZHow to clear file name and file path information?Most variables can be cleared by
var = [];
When I treid to do the same thing for my file name and path like below:
app.File.Value = [];
app.Path.Value = [],
I get this error:
Error using matlab.ui.control.EditField/set.Value
'Value' must be a character vector or a string scalar.
What is a better way of clearing these two variables? Thanks!
Leonhttps://se.mathworks.com/matlabcentral/profile/authors/3133287-leontag:se.mathworks.com,2005:Question/4741422019-07-30T16:26:54Z2019-10-20T17:19:44ZgTruth files not loading if generated from previous release of MATLAB?I have some gTruth files that were generated in R2018a. When i try to load them in R2018b, I get an error:
Warning: While loading an object of class 'groundTruth':
The function '@(varargin)validateLabelDefEntry(columnNames,varargin{:})' returned a non-scalar value when applied to the 1st row.
I can load gTruth files that were generated in R2018b in R2018a. How can i get this resolved? I really do not want to re-create gTruth files as it is a HUGE undertaking. Any help would be greatly appreciatedDerrick Bennetthttps://se.mathworks.com/matlabcentral/profile/authors/14082895-derrick-bennetttag:se.mathworks.com,2005:Question/4863612019-10-20T03:00:09Z2019-10-20T17:17:54Zresize image on readI am working with very high-resolution images, where reading in the image takes most of the processing time. Is there a more efficient method of reading a resized version of the image than X = imresize(imread('img.png'), ratio)?
The documentation for imread mentions a 'ReductionLevel' parameter, but it isn't present for my images. Moreover, it doesn't provide the same level of flexibility as imresize.
Note: I can't save a resized version of the image, since the resizing ratio changes depending on the algorithm and storage becomes an issue.
Thanks for the help!Nathan Jessurunhttps://se.mathworks.com/matlabcentral/profile/authors/12114956-nathan-jessuruntag:se.mathworks.com,2005:Question/4863512019-10-20T01:01:58Z2019-10-20T17:15:00ZDeep Learning Speech Recognition Example, Problem with designAuditoryFilterBankHi,
I am trying to run the Deep Learning Speech Recognition Example (see link: https://www.mathworks.com/help/deeplearning/examples/deep-learning-speech-recognition.html) and I am having a proble with designAuditoryFilterBank. The error that I am getting is: "Undefined function or variable 'designAuditoryFilterBank'."
I check to see if I have Audio toolbox installed and I do....Katarina Vuckovichttps://se.mathworks.com/matlabcentral/profile/authors/14092899-katarina-vuckovictag:se.mathworks.com,2005:Question/4864272019-10-20T17:11:10Z2019-10-20T17:11:10ZWhy accessing to table is slower than accessing to struct? Hi all,
I have a very large dataset of table data type with nested struct. I have carried out two scrips, one which deals with the table and the other with struct by converting the table into a struct (with the table2struct function). However, it seems that dealing with struct is much faster than dealing with the table. Below you will find a sample of my code. For most of the lines, there is no real difference between the two scripts, with the exception of the following that is inside a for-loop and therefore it significantly impacts on the overall script performance. Why such big difference? Is there a way to make it faster?
Sigs{iSig2Load(j)}(Pos2Paste)=single(messageStruct(i).Signals.(Sig{iSig(j)}));
Thank you,
Best regards.
SigNames={'s1','s2','s3','s4','s5'; 'a1','a1','a1','a2','a2'};
MessLength=40;
for i=1:2:MessLength
messageStruct(i).Name='a1';
messageStruct(i).Signals.s1=1;
messageStruct(i).Signals.s2=2;
messageStruct(i).Signals.s3=3;
end
for i=2:2:MessLength
messageStruct(i).Name='a2';
messageStruct(i).Signals.s4=4;
messageStruct(i).Signals.s5=5;
end
tic
UniqueMessFound=unique({messageStruct.Name});
UniqueMessageCount=countcats(categorical({messageStruct.Name},UniqueMessFound));
for iSig=1:length(SigNames(1,:))
Sigs{iSig}=NaN(UniqueMessageCount(strcmp(UniqueMessFound,SigNames{2,iSig})),1);
end
for i=1:MessLength
Sig=fieldnames(messageStruct(i).Signals);
[~,iSig2Load , iSig]=intersect(SigNames(1,:),Sig);
Sig2Sel=SigNames(1,iSig2Load);
for j=1:length(Sig2Sel)
Pos2Paste=find(isnan(Sigs{iSig2Load(j)}),1);
Sigs{iSig2Load(j)}(Pos2Paste)=single(messageStruct(i).Signals.(Sig{iSig(j)}));
end
end
toc
%%
SigNames={'s1','s2','s3','s4','s5'; 'a1','a1','a1','a2','a2'};
MessLength=40;
for i=1:2:MessLength
messageStruct(i).Name='a1';
messageStruct(i).Signals.s1=1;
messageStruct(i).Signals.s2=2;
messageStruct(i).Signals.s3=3;
end
for i=2:2:MessLength
messageStruct(i).Name='a2';
messageStruct(i).Signals.s4=4;
messageStruct(i).Signals.s5=5;
end
tic
message=struct2table(messageStruct);
UniqueMessFound=unique(message.Name);
UniqueMessageCount=countcats(categorical(message.Name,UniqueMessFound));
for iSig=1:length(SigNames(1,:))
Sigs{iSig}=NaN(UniqueMessageCount(strcmp(UniqueMessFound,SigNames{2,iSig})),1);
end
for i=1:MessLength
Sig=fieldnames(message.Signals{i});
[~,iSig2Load , iSig]=intersect(SigNames(1,:),Sig);
Sig2Sel=SigNames(1,iSig2Load);
for j=1:length(Sig2Sel)
Pos2Paste=find(isnan(Sigs{iSig2Load(j)}),1);
Sigs{iSig2Load(j)}(Pos2Paste)=single(message.Signals{i}.(Sig{iSig(j)}));
end
end
toc
Michele Mattettihttps://se.mathworks.com/matlabcentral/profile/authors/4391864-michele-mattettitag:se.mathworks.com,2005:Question/4863342019-10-19T21:56:22Z2019-10-20T17:10:43ZGetting rid of a for loopIf I have my code as
function [value1, value2] = scope(input)
c=1;
x=length(input);
for z=2:x
if z==x
break
elseif input(z-1)>input(z) && input(z)<input(z+1)
value1(c,1)=z;
value2(c,1)=input(z);
c=c+1;
end
end
Is it possible to get rid of the for look so the function runs without loops. Thank you.jacob Mitchhttps://se.mathworks.com/matlabcentral/profile/authors/16429293-jacob-mitchtag:se.mathworks.com,2005:Question/4861182019-10-18T11:19:18Z2019-10-20T16:53:18ZMat2Cell error when splitting an image up into smaller imagesHello, i have a large Image (3200 x 14444 pixels). I want to split it into subimages. Im using mat2cell but Im getting the error as shown below.
blockSizeRow=512
blockSizeCol=256
function blockImages = splitImageIntoBlocks(image, blockSizeRow, blockSizeCol)
% blockSizeRow: Rows in block
% blockSizeCol: Columns in block
[nrows, ncols] = size(image);
% Calculate size of each block by rows and columns
nBlocksRow = floor(nrows / blockSizeRow);
nBlocksCol = floor(ncols / blockSizeCol);
rowDist = [blockSizeRow * ones(1, nBlocksRow-1), rem(nrows, nBlocksRow) + blockSizeRow];
colDist = [blockSizeCol * ones(1, nBlocksCol-1), rem(ncols, nBlocksCol) + blockSizeCol];
blockImages = mat2cell(image, rowDist, colDist);
Error using mat2cell (line 89)
Input arguments, D1 through D2, must sum to each dimension of the input matrix size, [3200 14444].Jasonhttps://se.mathworks.com/matlabcentral/profile/authors/1217570-jasontag:se.mathworks.com,2005:Question/4864202019-10-20T16:42:11Z2019-10-20T16:42:11ZIncorrect ThingSpeak update feed error "error_payment_required" status 402 returnedI've created a new channel with two fields, field1=temp, field2=humidity. I'm trying to do either a bulk_update.json and update both fields at once (with the intention of queing data and updating a few datapoints at once, or using update.json and updating both fields at once for the channel every so many seconds.
I keep getting an error code returned in the JSON response, and the feeds never update. I also have tried pasting a URL for writing to one field and it returns "0". The fields in the channel never update.
My account is said to be a Free account, and it says I have 3,000,000 messages remaining, but the response error I get tells me I've exceeded the message limit for the ThingSpeak license and I need to upgrade my acount??? Why is this happening when my account says I haven't written one data point yet. I'm trying to write every 20 seconds to avoid the 15 second limit for the free account.
Trying to test this service to see if I may want to upgrade to a Home account...CWhttps://se.mathworks.com/matlabcentral/profile/authors/16626015-cwtag:se.mathworks.com,2005:Question/4864102019-10-20T15:04:44Z2019-10-20T16:42:01ZHow to get mean across cell array of arrays different size?Dear All, need your help ;) !
I have 1x5 cell array of arrays different size, like this :
myData = {{9×119×11},{6×119×11},{8×119×11},{9×119×11},{7×119×11}}
Across all of them , I need to find one avarage Array , like this : avrData = {9×119×11} .
I have tried next one (seebelow), but doubt if this is correct???
Thanks in advance!
myData = {{9×119×11},{6×119×11},{8×119×11},{9×119×11},{7×119×11}}
% with NaN I make the same size
for k = 1:length(myData)
m = size(myData{k},1);
myDatal{k}(m+1:9,:,:) = NaN; % with NaN I make the same size
end
% I summarize all of new Arrays
sum = myData{1};
for i = 2:length(myData)
sum = sum + myData{i};
end
% here is mean
meanData = sum ./ length(myData));
IMhttps://se.mathworks.com/matlabcentral/profile/authors/15407510-imtag:se.mathworks.com,2005:Question/4864192019-10-20T16:39:27Z2019-10-20T16:39:27ZFailure in initial objective function evaluation. LSQNONLIN cannot continue. I'm building a script to generate a non-linear least squares estimation, after enterring my data. I build the follwing code:
function [x,resnorm,residual,exitflag,output] = TrCalibrationBoyle(~)
clear all
global strike; global S0; global irate; global TTM; global mktprice; global N; global k;
strike=zeros(80,8);
S0=zeros(80,8);
irate=zeros(80,8);
TTM=zeros(80,8);
mktprice=zeros(80,8);
parameter=zeros(80,2);
res=zeros(80,1);
exit=zeros(80,1);
strike=xlsread('DATA1.xls','strike','A1:A80');
S0=xlsread('DATA1.xls','S0','A1:A80');
irate=xlsread('DATA1.xls','irate','A1:A80');
TTM=xlsread('DATA1.xls','TTM','A1:A80');
mktprice=xlsread('DATA1.xls','mktprice','A1:A80');
N=xlsread('DATA1.xls','N','A1:A80');
for i=80:-1:1
x0=[0.5,1.099]; lb=[0.001,1]; ub=[2,5]; k=i;
[x,resnorm,residual,exitflag]=lsqnonlin(@TrBoyleLSQD,x0,lb,ub);
parameter(i)=x; res(i)=resnorm; exit(i)=exitflag; tr_matrix=zeros(80,8);
for j=1:8
tr_matrix(i,j)=AmericanCallTrinBoyle(strike(i,j),S0(i,j),irate(i,j),TTM(i,j),x(1),x(2),N(i,j));
end
pricedata=[tr_matrix];
end
xlswrite('apotelesmata.xls',pricedata,'results','A1:A80');
xlswrite('apotelesmata.xls',res,'results','B1:A80');
xlswrite('apotelesmata.xls',parameter,'results','C1:C80');
end
The function whitc is included is:
function [trBoyle_lsqd] = TrBoyleLSQD(x)
global strike; global S0; global irate; global TTM; global mktprice; global N; global k;
trBoyle_lsqd=zeros(1,8);
for j=1:8
trBoyle_lsqd(j)=mktprice(k,j)-AmericanCallTrinBoyle(strike(k,j),S0(k,j),irate(k,j),TTM(k,j),x(1),x(2),N(k,j));
end
end
After i run TrCalibrationBoyle in the command window, it shows me the following:
Index in position 1 exceeds array bounds.
Error in TrBoyleLSQD (line 11)
trBoyle_lsqd(j)=mktprice(k,j)-AmericanCallTrinBoyle(strike(k,j),S0(k,j),irate(k,j),TTM(k,j),x(1),x(2),N(k,j));
Error in lsqnonlin (line 206)
initVals.F = feval(funfcn{3},xCurrent,varargin{:});
Error in TrCalibrationBoyle (line 35)
[x,resnorm,residual,exitflag]=lsqnonlin(@TrBoyleLSQD,x0,lb,ub);
Caused by:
Failure in initial objective function evaluation. LSQNONLIN cannot continue.
Do you have any ideas for what is the error? Violeta Oikonomouhttps://se.mathworks.com/matlabcentral/profile/authors/16466225-violeta-oikonomoutag:se.mathworks.com,2005:Question/4864142019-10-20T15:42:55Z2019-10-20T16:20:49ZCounting occurences of each number in a column when it's equal to all numbers in the same line?I have, for example, the following matrix P:
1 2 3
2 2 2
3 3 3
4 4 1
4 4 4
2 2 2
1 4 2
How can I count the occurences of each number in the first column, only when it's equal to all numbers in the same line? For this example, the result would be:
0
2
1
1
I've tried something like this:
alpha = unique(P);
O = zeros(size(alpha));
for k = 1 : length(alpha)
O(k) = sum(P(:,1) == alpha(k));
end
which counts the occurences for the first column of P, but I don't know how to exclude the cases where the line isn't all the same number. How should I alter my code?João Cabral Pintohttps://se.mathworks.com/matlabcentral/profile/authors/16264243-joao-cabral-pintotag:se.mathworks.com,2005:Question/4862082019-10-18T19:49:11Z2019-10-20T16:12:16ZProperty inspector can not be used any more on macI cannot use the property inspector in figure any more after the macos update.
dongfei chenhttps://se.mathworks.com/matlabcentral/profile/authors/15895741-dongfei-chentag:se.mathworks.com,2005:Question/4864162019-10-20T16:09:17Z2019-10-20T16:09:17ZIs it possible to get sections in MATLAB mobile?Is it possible to get sections in the mobile version of matlab (for an iPad Pro 10.5”) and then get the ”run section” function? Sigrid Tjernberghttps://se.mathworks.com/matlabcentral/profile/authors/16502894-sigrid-tjernberg