https://it.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2018-05-27T01:26:34Ztag:it.mathworks.com,2005:Question/3496592017-07-20T04:00:00Z2018-05-27T01:26:34ZHow can I make data files available to my code running on MATLAB Distributed Computing Server?<p>I have a MATLAB program which uses some data files. These files are currently stored on my local computer. I can use these data files without issue when running parallel code on my local machine, but when I try to run on my MATLAB Distributed Computer Server cluster, I receive errors saying that the files cannot be found.</p><p>How can I make these data files available to my code running on the cluster?</p>MathWorks Support Teamhttps://it.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:it.mathworks.com,2005:Question/4008682018-05-15T14:43:20Z2018-05-27T01:12:16ZMatlab database toolbox writting error<p>Error using database.odbc.connection/sqlwrite (line 218)
ODBC JDBC/ODBC Error: ODBC Driver Error: .</p>Alex Fernandezhttps://it.mathworks.com/matlabcentral/profile/authors/8575462-alex-fernandeztag:it.mathworks.com,2005:Question/4027192018-05-27T00:57:59Z2018-05-27T01:00:20ZClassification Learner App - generate a more generic function for your model training that could take varying size of prediction tables? One step beyond the default function generation<p>This is a question with an answer, that could easily translate into a feature implementation.
When one generates a function from a Classification Learner App on a found model, typically the Function content is really static:</p><p>1) It is tied to the original Prediction Table Column Names / Properties.
2) As a consequence, the function cannot be used on a different table that might have more or less columns [but where we still have y as the last column] (why would you do that is another topic all-together).</p><p>I found that modifying the original function file with the below function:</p><pre> function nameNewExt = aAdjustTrainClassifier(~,trainClassFile)
% aAdjustTrainClassifier
%
%
fidi=fopen(trainClassFile,'r');
[~,name,~]=fileparts(trainClassFile);
nameNew = strcat('aAdjusted_',name);
nameNewExt = strcat(nameNew,'.m');
if exist(nameNewExt, 'file') == 2
% file already exists, no overwrite ...
else
fido=fopen(nameNewExt,'w');
while ~feof(fidi)
l=fgetl(fidi); % read line
if startsWith(l,'predictorNames = ')
% modify line here
l='predictorNames = inputTable.Properties.VariableNames(:,1:end-1);';
elseif startsWith(l,'isCategoricalPredictor = ')
l='isCategoricalPredictor = false(1,length(predictorNames));';
elseif contains(l,strcat('function [trainedClassifier, validationAccuracy] ='," ",name,'(trainingData)'))
l=strcat('function [trainedClassifier, validationAccuracy] ='," ",nameNew,'(trainingData)');
elseif startsWith(l,'trainedClassifier.RequiredVariables = ')
l=strcat('trainedClassifier.RequiredVariables ='," ",'inputTable.Properties.VariableNames(:,1:end-1)');
end
fprintf(fido,'%s\n',l); % 'fgetl returns \n so it's embedded
end
fclose(fido);
end
fclose(fidi);
fclose('all');
end </pre><p>does the trick. Some static assumptions made (as for my use-case), and this might not work in all instances, however - would be grateful if you could provide feedback / improvements.
Another reason for posting is - this could easily translate into a GREAT feature to be implemented.</p><p>Thanks</p>Andreihttps://it.mathworks.com/matlabcentral/profile/authors/4508876-andreitag:it.mathworks.com,2005:Question/4027162018-05-27T00:31:19Z2018-05-27T00:50:19Zi have some problem in my code as call function and other syntax error .... anyone can help me to run the code correctly ..... the attachment files below <p>please i applied the step to call function but doesnt success .... help me please</p>Moath Maqablehhttps://it.mathworks.com/matlabcentral/profile/authors/9782897-moath-maqablehtag:it.mathworks.com,2005:Question/4027152018-05-27T00:27:13Z2018-05-27T00:48:24ZHow to get invisible panel to resize with figure window?<p>Hey!</p><p>I'm using two uipanels stacked in a figure window. I make one invisible, and I was wondering if it was possible to make this invisible uipanel resize when the figure window was resized. I'm using 2017b.</p>Clayton Birchenoughhttps://it.mathworks.com/matlabcentral/profile/authors/7115646-clayton-birchenoughtag:it.mathworks.com,2005:Question/4027182018-05-27T00:43:43Z2018-05-27T00:43:43ZDifference between a table and a matrix<p>What is a difference between a "table" and a matrix?</p><p>One can use save command to write a matrix data to a file. Can one use the same save command to write a table to a file?</p>alpedhuezhttps://it.mathworks.com/matlabcentral/profile/authors/10930090-alpedhueztag:it.mathworks.com,2005:Question/4025572018-05-25T13:18:38Z2018-05-27T00:40:59Zvpasolve and solve return empty sym 0-by-1, SOLUTION DOES EXIST<p>When I run this code I get empty strings for when setting a range for vpasolve, when I do not set the range I only get one solution, even with random on. The range is set so that it does include the one solution matlab gives me, x=2, y=0 and b=1.5. for the range I've tried -Inf Inf and NaN NaN, to have it try all numbers. So please do not give me the answer of saying that my system has no solution, it clearly does. It also won't solve it symbolicly (same issue with solve), while I can give 1 possible solution. 0.5*(x+y)=1, b*(x+y)=3 ---> x+y=2 and b=1.5</p><p>So something else must be wrong, I would appreciate it if you let me know what I'm doing wrong here.</p><pre class="language-matlab">clear all; %just to be safe
syms x y b
a=0.5;
somevalue=1;
someothervalue=3;
eq1= a*x+a*y == somevalue; %this is your first equation
eq2= b*x+b*y == someothervalue; %this is your 2nd equation
eqs=[eq1,eq2]; %use this for vpasolve and set range in range
vars=[x,y,b]; %these are the variable you want to solve for
range = [-1 3; -2 5; -Inf Inf]; %NaN means you set no range
</pre><pre class="language-matlab">%you can use solve or vpasolve, second one being numeric, which is the one you'll probably want
sol=zeros(5,3);
for i = 1:5
temp1 = vpasolve(eqs, vars, range, 'random', true);
temp = solve(eqs, vars);
sol(i,1) = temp.x;
sol(i,2) = temp.y;
sol(i,3) = temp.b;
end
sol
temp1.x
temp1.y
temp1.b
</pre><p>Now I have another clear problem/error when using the solve option, obviously the answer here should be 9:</p><pre class="language-matlab">syms x
eq12 = -3 == sqrt(x);
solve(eq12)
ans =
Empty sym: 0-by-1
</pre>Bob photonicshttps://it.mathworks.com/matlabcentral/profile/authors/9446342-bob-photonicstag:it.mathworks.com,2005:Question/4027172018-05-27T00:40:57Z2018-05-27T00:40:57Zfunction to import varying size text file automatically ? - one step beyond the Import Data Wizard<p>Hello,</p><p>The Import Data Wizard is a great little tool to use on one file, say "Customers_1.txt" ... then the user gets presented with 3 options:</p><p>1) Import Data
2) Import Script
3) Import Function</p><p>Now ... question: WHY would you want to generate a Function if not to automate a process?
Why would you want to automate a process if not for dynamically import various other similar files to "Customers_1.txt"?
Another fair assumption:
Why would the the {Import Wizard -> Generate a Function} developer think that "Customers_N.txt" file which will be imported further down the line as part of an automated process (using this generated function), is similar in size (as in Number of Columns) as "Customers_1.txt" that was used to generate the function? They all may be similar in syntax, types and logic but some files might have more columns than other (where new columns is new data, not new features).</p><p>This is the default: any function generated is hard-coded on the initial file in terms of nr of columns such as in the below:</p><pre class="language-matlab">%% Initialize variables.
delimiter = ',';
if nargin<=2
startRow = 1;
endRow = inf;
end
</pre><pre class="language-matlab">%% Format for each line of text:
% column1: double (%f)
% column2: double (%f)
...
% column8550: double (%f)
% For more information, see the TEXTSCAN documentation.
formatSpec = '%f%f%f%f%f...
</pre><p>Which to me, is half as useful.
This might easily translate into a feature enhancement on the way import functions are generated, but meanwhile:</p><p>QQQ: Is it possible to generate a function from GUI to dynamically load files larger (in terms of nr or columns) than the original one? If not, how would you approach modifying the resulted function to make it more general?</p><p>Thanks</p>Andreihttps://it.mathworks.com/matlabcentral/profile/authors/4508876-andreitag:it.mathworks.com,2005:Question/4027112018-05-26T23:29:40Z2018-05-27T00:38:15ZHow do I solve over determined system of non linear equation?<p>Suppose I have three matrices A,B,X. A and B being now and size 200x4. X being unknown with size 3x4. The system is AX=B.</p><pre class="language-matlab">syms x1 x2 x3 x4 y1 y2 y3 y4 z1 z2 z3 z4
A = rand(200,4);
X = [ x1 x2 x3 x4; y1 y2 y3 y4; z1 z2 z3 z4];
B = rand(200,4);
</pre><p>I want solve for X while keeping x1 x2 x3 y1 y2 y3 z1 z2 z3 values constrained to [-1,1]. What is the best approach?</p>Ahmad Adeehttps://it.mathworks.com/matlabcentral/profile/authors/9148595-ahmad-adeetag:it.mathworks.com,2005:Question/4027142018-05-27T00:17:13Z2018-05-27T00:17:13ZHow to create a function to change the color of a pushbutton?<p>Hello, I've an application that changes the color of a pushbutton but I have 25 pushbuttons and I don't want to copy/paste the code, how can I create a function that recieves the button as a parameter and change the color? here's the code:</p><pre class="language-matlab">% --- Executes on button press in cell11.
function cell11_Callback(hObject, eventdata, handles)
color=get(handles.cell11,'BackgroundColor');
if(color==[0.94,0.94,0.94])
set(handles.cell11,'BackgroundColor',[0,0,0]);
elseif(color==[0,0,0])
set(handles.cell11,'BackgroundColor',[0.94,0.94,0.94]);
end
% hObject handle to cell11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
</pre>Daniel Gomezhttps://it.mathworks.com/matlabcentral/profile/authors/12122993-daniel-gomeztag:it.mathworks.com,2005:Question/4027132018-05-27T00:16:02Z2018-05-27T00:16:02ZSimscape - Allow accumulator to fully discharge without model crashing?<p>Hello I am currently trying to model a hydraulic circuit where a gas charged accumulator is fully pressurized initially and discharges through a motor into a reservoir. The motor spins a wheel through a gear ratio with rolling resistance and mass attached. I am trying to create a simple model for a hydraulic powered bike using the accumulator discharge to propel the vehicle and measure its final distance.</p><p>The current problem I am facing is when the fluid volume in the accumulator reaches zero, the model crashes saying</p><ul><li><i>At time 13.904426, one or more assertions are triggered. See causes for specific information.
Liquid pressure fell below absolute zero The assertion comes from:</i></li></ul><p>I found this error stems from my custom fluid configuration block displaying a error if the fluid absolute pressure falls below absolute zero.</p><p>Is there an easy to mitigate this problem either by blocking the flow from the accumulator entirely or by changing the solver configurations? I have switched the fluid configuration to display a warning instead of an error but then the model completely crashes and only displays data from the time when the accumulator volume hits zero and on.</p><p>I did want to place a logic controlled 2 way valve into the loop and once the pressure in the lines reached the precharge pressure in the accumulator it closes the valve, but the problem would probably still occur because there is leakage within the valve and the accumulator can still discharge through that.</p><p>Let me know if I am missing anything.
Any help is greatly appreciated. I have attached an image of the circuit. I can publish the actual model if necessary.</p><p>Thanks,
Nicholas</p>Nicholas Gholdoianhttps://it.mathworks.com/matlabcentral/profile/authors/7470703-nicholas-gholdoiantag:it.mathworks.com,2005:Question/4027012018-05-26T20:09:50Z2018-05-27T00:13:19ZMoving x point to compare<p>Hi everybody,</p><p>i have a small problem, maybe they can help me and i would be appreciate that.</p><p>I have two different brake-pressure data but my time was different measured (so x-axes). I want to move my green graph move left, so like above blau one, then i can compare it. Do you have solution for me?
Thank you already.</p><pre class="language-matlab">figure(2)
</pre><pre class="language-matlab">%subplot(2,2,1)
plot(Time, Bremsdruck_Rad_HL, cm.Time.data, cm.CAN_RB2_BREMSDRUCK_RAD_BRP_WHL_RLH.data);
ylabel ('Bremsdruck HL')
</pre><img src = "https://www.mathworks.com/matlabcentral/answers/uploaded_files/119135/Screenshot_2.png">Ayse Uhttps://it.mathworks.com/matlabcentral/profile/authors/12914539-ayse-utag:it.mathworks.com,2005:Question/4027122018-05-27T00:08:21Z2018-05-27T00:08:21ZCan you plot the gradient for CNNs using trainNetwork?<p>I am using the <i>trainNetwork</i> command to train my network, but noticed that there is no way to plot the gradients over iterations. The <i>trainInfo</i> output does contain some information, but does not seem to contain any information about the gradient.</p>Arjun Desaihttps://it.mathworks.com/matlabcentral/profile/authors/6899937-arjun-desaitag:it.mathworks.com,2005:Question/4027072018-05-26T22:19:10Z2018-05-26T23:53:16ZFind value of unknown in equation using solve<p>the equation is M = (4.5673*10^-5)*(tb^2.1962)*(0.893^(-1.0164))</p><p>value of M is given as M=[16.47;59.90;80;120;200]</p><p>how can i find the value of tb using the solve fuction?</p>Eiko Raidhttps://it.mathworks.com/matlabcentral/profile/authors/12914741-eiko-raidtag:it.mathworks.com,2005:Question/4027082018-05-26T22:37:53Z2018-05-26T23:48:03Z"Unable to perform assignment because the indices on the left side are not compatible with the size of the right side."<p>I am trying to use the following function but the error keeps occurring in Line 14:</p><pre class="language-matlab">function r = rxnrate(V,F)
global k Keq f P
Fa=F(1);
Fb=F(2);
Fc=F(3);
Fd=F(4);
Pa=(Fa./f)*P;
Pb=(Fb./f)*P;
Pc=(Fc./f)*P;
Pd=(Fd./f)*P;
Fa=Fb;
Fc=Fd;
f=Fa+Fb+Fc+Fd;
r(1)=-k.*((Pa.*Pb)-(Pc.*Pd./Keq));
r(2)=-k.*((Pa.*Pb)-(Pc.*Pd./Keq));
r(3)=k.*((Pa.*Pb)-(Pc.*Pd./Keq));
r(4)=k.*((Pa.*Pb)-(Pc.*Pd./Keq));
r=r';
end
</pre><p>I am also trying to use this function for the following script:</p><pre class="language-matlab">%This script will plot the respective flowrate versus the volume of
%the reactor for the following reaction:
%CO + H2O <--> CO2 + H2 where CO = A, H2O = B, CO2 = C, H2 = D
clear all;
clc;
P=1; %System pressure in atm
R=8.314*10^-3; %Ideal gas constant in kJ/mol*K
k0=6.195*10^8; %Reference rate constant in mol/(atm^2*m^3*min)
f=33; %Inlet molar flowrate in kmol/min
Fao=(0.5*f); Fbo=(0.5*f); Fco=0; Fdo=0; %Inlet flow rates for all species
T1=450; %System temperature in K
T2=550; %System temperature in K
T3=650; %System temperature in K
</pre><pre class="language-matlab">k=k0*exp(-47.53/(R*T1)); %Rate constant with respect to temperature
Keq=exp((4577.8/T1)-4.33); %Equilibrium constant with respect to temperature
V=[0 0.25];
Fo=[Fao Fbo Fco Fdo];
[V,F]=ode45(@rxnrate,V,Fo);
plot(V,F);
</pre><p>Thank you for the help!</p>Matthew Tomhttps://it.mathworks.com/matlabcentral/profile/authors/12691990-matthew-tomtag:it.mathworks.com,2005:Question/4024482018-05-24T21:57:50Z2018-05-26T23:29:09ZWhy does MarkerFaceColor in Figure look like crinkled aluminum foil rather than a single color?<p>Attached is a Figure with 40-50 data points showing the value of D at specific values of x and y. MarkerSize and MarkerFaceColor are controlled by two LUT's so that small values of D give small spots colored blue and large values of D have large spots colored red. Until recently, the code behaved as expected, each marker having one color. Now the markers have weird radial streaks ("crinkles"). Any suggestions on where the crinkles in MarkerFaceColor might be coming from?
The colormap is 'jet', but changing the colormap did not solve the problem.
Thank you for your help.</p>george. holzwarthhttps://it.mathworks.com/matlabcentral/profile/authors/19652-george-holzwarthtag:it.mathworks.com,2005:Question/4027102018-05-26T23:17:19Z2018-05-26T23:17:19ZSignal Non-uniform re-sampling<p>Please find the attached file which is a 625000x1 signal variable y(t)
I also have time series t=0:dt:64-dt; which correspond to y(t) numerically.</p><p>if I need a nonlinear time transformation to make h(t)=sqrt(t.^2+const);
const=3 sec for instance.</p><p>How do I extract y(h(t)) for t=0:dt:5 for instance?
The length of the vector would be different from 625000x1 of course.
Thank you!!</p>Tsuwei Tanhttps://it.mathworks.com/matlabcentral/profile/authors/9173023-tsuwei-tantag:it.mathworks.com,2005:Question/4026952018-05-26T18:35:24Z2018-05-26T23:14:11ZHow to access data with more than 524288 elements?<p>Hi,</p><p>I've got the problem to access my data. There are 46 cells and each cell contains 480x640x3 uint8.</p><p>I cannot display summaries of variables with more than 524288 elements on the workspace.</p><p>Please have a look at the attached image since pictures speak louder than words.</p><img src = "/matlabcentral/answers/uploaded_files/119131/can't.png"><p>I've tried to extract into individual RGB channel but it is not working for all frames. It's only showed the first frame and got an error 'Index exceeds matrix dimensions'.</p><pre class="language-matlab">load('X:\data_depth\cf1','imagecolor');
[a,~]=size(imagecolor{1,1});
image=imread('X:\data\template.png');
</pre><pre class="language-matlab">counter=1;
for i = 1:length(imagecolor)
imagesc(imagecolor{i})
redChannel = i(:, :, 1);
greenChannel = i(:, :, 2);
blueChannel = i(:, :, 3);
</pre><pre> pause(0.1)
counter = counter + 1;
end</pre><p>How to get the variables of 480x640x3 uint8 in each cell?</p><p>Help me, please...</p><p>Thank you</p><p>Regards</p><p>Hana</p>hana razakhttps://it.mathworks.com/matlabcentral/profile/authors/3597202-hana-razaktag:it.mathworks.com,2005:Question/4027092018-05-26T23:06:12Z2018-05-26T23:06:12ZSave data after each simulation<p>I am running a Matlab script which opens up a Simulink model and runs the simulation several times within a for-loop.I have a Uniform Random Number Block in my model, so the output of the Simulation will be different in each run. The problem I have is that if I run the simulation 20 times via my Matlab script, the output variable is overwritten in the workspace after each run. Is there a way to save the output variable in my workspace after each run with a different name and still be able to have my script run the simulation as many times as I want automatically?</p>Mucenica Claudiuhttps://it.mathworks.com/matlabcentral/profile/authors/12363166-mucenica-claudiutag:it.mathworks.com,2005:Question/4026962018-05-26T18:36:57Z2018-05-26T23:01:00ZHave a problem on my code could you help me? URGENT<pre class="language-matlab">a2=28
ctheta3=cos(1:1:360)
stheta3=sin(1:1:360)
a3=39
stheta2=sin(1:1:360)
ctheta2=cos(1:1:360)
s=(a2*ctheta2)+(a3*ctheta3)
e=-((a2*stheta2)+(a3*stheta3))
</pre><pre class="language-matlab">subplot(3,2,1),plot(s,'c'),xlabel('Posición'),ylabel('Tiempo'),title('Grafica de posición s','FontSize',12)
subplot(3,2,2),plot(e,'r'),xlabel('Posición de e'),ylabel('Tiempo'),title('Grafica de posición e','FontSize',12)
DCt3=diff(ctheta3)
DSt3=diff(stheta3)
DCt2=diff(ctheta2)
DSt2=diff(stheta3)
W3=(a2*DCt2)./(a3*ctheta3)
subplot(3,2,3),plot(W3,'g'),xlabel('Velocidad de theta3'),ylabel('Tiempo'),title('Grafica de velocidad angular de theta3','FontSize',12)
</pre><pre class="language-matlab">Matrix dimensions must agree.
</pre><p>my problem is when i want to get W3 from the math equations!</p>Gerard Navahttps://it.mathworks.com/matlabcentral/profile/authors/12142814-gerard-navatag:it.mathworks.com,2005:Question/3837612018-02-20T17:24:16Z2018-05-26T22:50:48ZHow Can I Modify Weights in a SeriesNetwork of a CNN Model ?<p>Hi, Everyone. I have run a CNN example of Matlab R2017b to classify images of digits 0-9 and the code of this example is shown below :</p><pre class="language-matlab">if true
% Loading Data and Splitting them to the Training and Testing Data Set
digitDatasetPath = fullfile(matlabroot,'toolbox','nnet','nndemos',...
'nndatasets','DigitDataset');
digitData = imageDatastore(digitDatasetPath,...
'IncludeSubfolders',true,'LabelSource','foldernames');
trainingNumFiles = 750;
rng(1) % For reproducibility
[trainDigitData,testDigitData] = splitEachLabel(digitData,...
trainingNumFiles,'randomize');
% Defining Layers
layers = [imageInputLayer([28 28 1]);
convolution2dLayer(5,20);
reluLayer();
maxPooling2dLayer(2,'Stride',2);
fullyConnectedLayer(10);
softmaxLayer();
classificationLayer()];
% Training the convnet
options = trainingOptions('sgdm','MaxEpochs',20,...
'InitialLearnRate',0.0001);
convnet = trainNetwork(trainDigitData,layers,options);
end
</pre><p>Actually, I want to modify weights of this Network, for example, I would like to Multiply weights of first convolutional layer by 0.5, but I have received this error:</p><p>"You cannot set the read-only property 'Layers' of SeriesNetwork"</p><p>Is there any solution for this problem?</p><p>Thank you for advising me on this topic.</p><p>Reza.</p>Reza Akbarihttps://it.mathworks.com/matlabcentral/profile/authors/11357719-reza-akbaritag:it.mathworks.com,2005:Question/4027062018-05-26T21:55:45Z2018-05-26T21:56:16Zhow can i show a pulse signal in simulink?<p>i have an arduino one with a external pulse signal i use an arduino input connected to the scope but it shows just a line in zero.</p><img src = "/matlabcentral/answers/uploaded_files/119136/pulse%20signal.png">felix jose chavez torreshttps://it.mathworks.com/matlabcentral/profile/authors/10526503-felix-jose-chavez-torrestag:it.mathworks.com,2005:Question/4027052018-05-26T21:55:28Z2018-05-26T21:55:28ZHow to fix this "Build error: C compiler produced errors. See the target build log for further details"?<p>Please help me, i dont understand is what the error from my code.
I try to build C++ code from matlab coder. When i try with simple code, it work. But when i try with my real code, i have error.
The message, "Build error: C compiler produced errors. See the target build log for further details."
And when i see target build log, there are some messages.
1. The system cannot find the path specified
2. Warning : there is no short path from "my path"</p>Dicki Andreahttps://it.mathworks.com/matlabcentral/profile/authors/12057054-dicki-andreatag:it.mathworks.com,2005:Question/4027042018-05-26T21:15:22Z2018-05-26T21:35:41ZSlider to scroll through image slices<p>I need a code for a slider to scroll through a stack of images. Like a 3D Viewer.</p><p>Any idea please? I have 4 axes and need to control them with a single slider.</p>Stelios Fanourakishttps://it.mathworks.com/matlabcentral/profile/authors/10865530-stelios-fanourakistag:it.mathworks.com,2005:Question/4023092018-05-24T09:15:37Z2018-05-26T21:33:49ZGUI 'uitable' with option to add rows using push button for string<p>Hi, Guys, I want to add a string to new rows in Uitable Matlab but have errors</p><pre class="language-matlab">if true
data = get(handles.uitable, 'data');
if iscell(data); data = cell2mat(data); end
data(end+1,:) = ['june' ,12];
set(handles.uitable, 'data', data);
</pre>Emir azhttps://it.mathworks.com/matlabcentral/profile/authors/12655615-emir-aztag:it.mathworks.com,2005:Question/4026842018-05-26T16:35:11Z2018-05-26T21:28:52ZFind unknown from the equation with given values<p>I'm try to find the value of an unknown from an equation.</p><p>for simplicity sake,</p><p>values of a = [1;2;3;4]</p><p>a = b + 1</p><p>how do i find values of b for each values of a?</p><p>thank you so much in advance</p>MUHAMMAD AZFAR BIN ISMAILhttps://it.mathworks.com/matlabcentral/profile/authors/11635671-muhammad-azfar-bin-ismailtag:it.mathworks.com,2005:Question/4026192018-05-25T20:35:49Z2018-05-26T21:16:27Zreshape of complex numbers into matrix<p>hi,
I have the following I/Q and I would like to reshape them in a matrix but I get exception</p><pre class="language-matlab">x = complex(ResultI, ResultQ);
D=64;
len = length(x);
m1=reshape(x,len/D,D); %generating matrix ---> each row showing range info for one period AND each column showing number of periods
</pre>Ahmed Tolbahttps://it.mathworks.com/matlabcentral/profile/authors/12897258-ahmed-tolbatag:it.mathworks.com,2005:Question/4026462018-05-26T05:43:33Z2018-05-26T21:13:56Zhi. i am working on a speaker recognition project. can anyone tell which is the best technique to remove background noise? which is the best filter for this? which method i should adapt to reduce background noise of speech signal?<p>hi. i am working on a speaker recognition project which will also detect the use of doctorate tool if speech signal is manually altered</p>Abdul Basithttps://it.mathworks.com/matlabcentral/profile/authors/12722833-abdul-basittag:it.mathworks.com,2005:Question/4027022018-05-26T20:15:12Z2018-05-26T21:08:46ZProblems with Indexing of cell array <p>Hi guys!</p><p>The problem I have is the following:
I have a dictionary with names and with one picture. I create a randomized sequence for my pictures. Now I want to display (via Psychtoolbox) the respective Name Cues for the image, but in randomized order.
Hopefully my code snippet does show you what I mean:</p><pre> nameCues1 = {'Lisa','Anna', 'Sarah', 'Nina', 'resized_1.jpg' };
nameCues2 = {'Emma', 'Lena', 'Gabi', 'Steffi', 'resized_2.jpg' };
nameCues3 = {'Tanja', 'Luisa', 'Jana', 'Nicole', 'resized_3.jpg' };
nameCues4 = {'Clara', 'Tina', 'Katja', 'Susi', 'resized_4.jpg' };</pre><p>I have loaded them into a cell array:</p><pre> nameCuesAll = {nameCues1,nameCues2, nameCues3}</pre><p>Now I create a randomized sequence:</p><pre> randSeq3 = nameCuesAll(randperm(size(nameCuesAll,2)));</pre><pre> %% Loop for Rating Phase
% Reads facial stimuli for "Explicit Recognition Phase"
for i = 1:numel(nameCuesAll)</pre><pre> pics3{i} = imread(randSeq3{i}{1,5});
ind{i}=randperm(numel(randSeq3{i}));</pre><pre> ind{i}=randSeq3{i}{ind}; %this doesn't work yet!</pre><pre class="language-matlab">end
</pre><p>Then I prompt in on the Screen via the function of Psychtoolbox:</p><pre> for j = 1:4
%%here I leave out some unnecessary functions of Psychtoolbox </pre><pre> DrawFormattedText(window,ind{i}(j), 'center', 'center', white, [], [], [], [], [], rect);</pre><pre> end</pre><p>I put in some hard hours, but didn't come close to a sufficient solution. I would be very glad if someone could help me out here.</p><p>Thanks so much!</p>PRhttps://it.mathworks.com/matlabcentral/profile/authors/10595089-prtag:it.mathworks.com,2005:Question/4026832018-05-26T16:30:57Z2018-05-26T21:02:19Zy = imread(file1, 'BackgroundColor', [1 1 1]); WHAT DOES IT DO? <p>I am getting an error in this line as:</p><pre class="language-matlab">Error using strfind
Input strings must have one row.
</pre><pre class="language-matlab">Error in getFileFromURL (line 8)
if (strfind(filenameIn, '://'))
</pre><pre class="language-matlab">Error in imread (line 327)
[isUrl, filename] = getFileFromURL(filename);
</pre><pre class="language-matlab">Error in oooo (line 63)
y = imread(I, 'BackgroundColor', [1 1 1]);
</pre>SURILA GUGLANIhttps://it.mathworks.com/matlabcentral/profile/authors/12427724-surila-guglanitag:it.mathworks.com,2005:Question/4027032018-05-26T20:40:06Z2018-05-26T21:00:19ZFIS file in VHDL/Verilog code.<p>There is a fis file created in the graphic interface of Fuzzy Inference System . This unit I need to use in quartus II to create a fuzzy traffic light based on Altera Cyclone IV. How do I translate this fis block (to matlab) into vhdl/verilog code to create a fuzzy block in quartus II?</p>Alexander Shimhttps://it.mathworks.com/matlabcentral/profile/authors/12481287-alexander-shimtag:it.mathworks.com,2005:Question/4026662018-05-26T11:51:27Z2018-05-26T20:27:02Zfor finding samples (1;1500000) steady state mean value w.r..t normal distribution (upper and lower limit)<p>I have sample readings of experiments(V2 I2 V1 I1)containing(1;1500000) samples,details of question are as,</p><pre class="language-matlab">yfilt = smooth(y,500); % filter the readings
figure
plot(y) % plot y without filter
hold on
plot(yfilt) % plot y with filter
</pre><pre class="language-matlab">mu = mean(yfilt(10e5:15e5)); % calculate mean from sample (10e5:15e5)
sigma = std(yfilt(10e5:15e5)); % calculate mean from sample (10e5:15e5)
</pre><pre class="language-matlab">figure
hold on
plot(yfilt)
plot([0 15e5],[mu+3*sigma mu+3*sigma]) % plot Upper limit from (0;15e5) samples on plot
plot([0 15e5],[mu mu]) % plot Mean form (0;15e5) samples on plot
plot([0 15e5],[mu-3*sigma mu-3*sigma]) % plot Lower limit from (0;15e5) samples on plot
</pre><img src = "https://www.mathworks.com/matlabcentral/answers/uploaded_files/119107/Mean%20value%20for%20nomal%20distributed%20samples.png"><p>I need to find steady state mean value from readings (10e5;15e5) Confidence intervals
(mu+3*sigma mu-3*sigma]) and mean=mu.corresponding to normal distribution(that is 99.73% of samples fall within confidence interval)</p><p>The condition i need to check are as,</p><p>For Sample from starting(10e5:15e5)</p><p>#Count Samples
Samples> [mu-3*sigma mu-3*sigma]</p><p>check 99% of samples greater than [mu-3*sigma mu-3*sigma] limit</p><p>if No then K=K+1</p><p>If yes</p><p>check these samples w.r.t Mean</p><p>Samples> mu
Is 48% of samples greater than mu</p><p>if No, than K=K+1
if Yes than sample=k</p>amarjeet yadavhttps://it.mathworks.com/matlabcentral/profile/authors/7998941-amarjeet-yadavtag:it.mathworks.com,2005:Question/4027002018-05-26T19:37:17Z2018-05-26T20:16:51Z I'm trying to make logic gates in the GUI ( app designer) but when i put the logical expression i get the error saying Value must be double scalar, How do i fix this ? Please help.<pre> a = app.val1.Value;
b = app.val2.Value;
app.result.Value = a & b;</pre><p>Error using matlab.ui.control.internal.model.AbstractNumericComponent/set.Value (line 110)
'Value' must be a double scalar.</p>Abdul wadood Mohammedhttps://it.mathworks.com/matlabcentral/profile/authors/12686060-abdul-wadood-mohammedtag:it.mathworks.com,2005:Question/4026992018-05-26T19:24:45Z2018-05-26T20:07:36ZWhy is there an "inifite recursion"?<p>Hello,</p><p>I am currently trying to implement an more efficient algorithm to compute the greatest common divisor, which uses the hgcd. The Problem is that MATLAB goes into an infite recursion, although I don't know why.</p><pre class="language-matlab">function [M] = hgcd(p, q)
%hggT Ergibt den halbrößten gemeinsamen Teiler
% ||p|| > ||q||
</pre><pre class="language-matlab">GradP = size(p)-1; %Hier wird Grad(p) und Grad(q) bestimmt
GradQ = size(q)-1;
GradP = GradP(1,2);
GradQ = GradQ(1,2);
m = ceil(GradP / 2);
if GradQ < m %1. Fall: Der hgcd ist die Einheitsmatrix
M = [1 0; 0 1];
else
XhochM = [1, zeros(1, m)]; %Hier wird das Polynom x^m gebildet
p_0 = deconv(p, XhochM); %Polynomdivision ist der deconv()-Befehl
q_0 = deconv(q, XhochM);
R = hgcd(p_0, q_0); %Rekursiver aufruf
q = [zeros(1, GradP - GradQ), q]; %Fügt führende Nullen ein, damit p und q gleich groß sind
R_inv = RegPolMatrixInv(R); %Invertiert R
v = ConvPolMatrix3(R_inv, [p; q]); %Mulitipliziert R_inv und die Matrix [p \\ q]
Groesse = size(v); %Im Folgenden wird v in p und q aufgeteilt
Groesse = Groesse(1,2);
for i = 1:Groesse
pStrich(i) = v(1,i);
qStrich(i) = v(2,i);
end
while qStrich(1)==0 %Löscht führende Nullen
qStrich(1) = [];
end
GradQStrich = size(qStrich)-1; %Bestimmt den Grad
GradQStrich = GradQStrich(1,2);
if GradQStrich < m %2. Fall: Hier sind wir mit M = R zuende
M = R;
else
[Q, s] = deconv(pStrich, qStrich); %Q ist Ergebnis der Polynomdivision, s ist der Rest
r = pStrich;
l = size(r)-1; %l = grad(r)
l = l(1,2);
k = 2*m-l;
XhochK = [1, zeros(k)]; %Erzeugt das Polynom x^k
r_0 = deconv(r, XhochK);
s_0 = deconv(s, XhochK);
S = hgcd(r_0, s_0);
Groesse2 = size(Q); %Dies ist notwendig, um <Q> zu erzeugen
Groesse2 = Groesse2(1,2);
Eins = [zeros(1, Groesse2)-1, 1]; %Das Polynom 1 mit führenden Nullen
Nulll = zeros(1, Groesse2); %Das Nullpolynom mit führenden Nullen
Q = [Q, Eins; Eins, Nulll]; %Erzeuge <Q>
M = R*Q*S;
end
end
end
</pre><p>Here is ConvPolMatrix3 a program that multiplies two Polynomial matrices, and RegPolMatrixInv a program that inverts any regular polynomial matrix. Their codes are the followings:</p><pre class="language-matlab">function [M] = ConvPolMatrix3(M, N)
%ConvPolMatrix3 N ist nur 2x1 Matrix.
% -----
</pre><pre class="language-matlab">h_1 = size(M);
h_2 = size(N);
h_1 = h_1(1,2);
h_2 = h_2(1,2);
h_1 = h_1 / 2;
for i = 1:h_1
p_11(1,i) = M(1,i);
p_12(1,i) = M(1,i+h_1);
p_21(1,i) = M(2,i);
p_22(1,i) = M(2,i+h_1);
end
for i = 1:h_2
q_11(1,i) = N(1,i);
q_21(1,i) = N(2,i);
end
</pre><pre class="language-matlab">r_111 = conv(p_11, q_11);
r_112 = conv(p_12, q_21);
r_211 = conv(p_21, q_11);
r_212 = conv(p_22, q_21);
g_111 = size(r_111)-1;
g_112 = size(r_112)-1;
g_211 = size(r_211)-1;
g_212 = size(r_212)-1;
g_111 = g_111(1,2);
g_112 = g_112(1,2);
g_211 = g_211(1,2);
g_212 = g_212(1,2);
Grad = max([g_111, g_112, g_211, g_212]);
r_111 = [zeros(1, Grad - g_111), r_111];
r_112 = [zeros(1, Grad - g_112), r_112];
r_211 = [zeros(1, Grad - g_211), r_211];
r_212 = [zeros(1, Grad - g_212), r_212];
r_11 = r_111 + r_112;
r_21 = r_211 + r_212;
i = 1;
while (r_11(i) == 0) && (r_21(i) == 0)
r_11(i) = [];
r_21(i) = [];
end
M = [r_11; r_21];
i = 0;
return
end
</pre><p>and, for RegPolMatrixInv,</p><pre class="language-matlab">function [M_inv] = RegPolMatrixInv(M)
%RegPolMatrixInv Invertiert eine reguläre Polynommatrix
% Suche M^-1 nach dem Adjunktensatz
</pre><pre class="language-matlab">h = size(M);
h = h(1,2);
h = h/2;
p_11 = zeros(1, h);
p_12 = p_11;
p_21 = p_11;
p_22 = p_11;
for i = 1:h
p_11(1,i) = M(1, i);
p_12(1,i) = M(1, i+h);
p_21(1,i) = M(2, i);
p_22(1,i) = M(2, i+h);
end
J = ConvPolMatrix(p_11, p_12, p_21, p_22, p_22, -p_12, -p_21, p_11);
if J ~= [1 0; 0 1]
det = -1;
else
det = 1;
end
M_inv = det*[p_22, -p_12; -p_21, p_11];
return
end
</pre><p>Now, the two functions RegPolMatrixInv and ConvPolMatrix3 work just fine, but whenever I try to run the main program hgcd, and the second case is true, MATLAB goes into an infite recursion. Could you please tell me why and how to fix it? Also, sorry for the german comments and bad programming.</p><p>Thanks for helping me,</p><p>Florian</p>Florian Albrechthttps://it.mathworks.com/matlabcentral/profile/authors/12071574-florian-albrechttag:it.mathworks.com,2005:Question/3873942018-03-09T19:23:35Z2018-05-26T20:00:53Zdrawnow's low speed<p>Hello,
I have written a code which animates the motion of a ball. Here is the code:</p><pre class="language-matlab">n = 100;
axes('XLim', [-10 10], 'YLim', [-10 10], 'ZLim', [-10 n]);
grid on
daspect([1, 1, 1])
axf = gca;
axf.Clipping = 'off';
material shiny
view(135, 10)
set(gcf, 'Renderer', 'opengl')
camlight right
lighting gouraud
xlabel('x')
ylabel('y')
zlabel('z')
[xsph, ysph, zsph] = sphere(500);
h = surface(10*xsph, 10*ysph, 10*zsph, 'FaceColor', 'r', 'EdgeColor', 'none');
w = hgtransform;
set(h, 'parent', w)
zp = 1:n;
yp = zeros(numel(zp));
xp = zeros(numel(zp));
ip = 1;
while ip < n
transr = makehgtform('translate', [xp(ip) yp(ip) zp(ip)]);
set(w, 'Matrix', transr);
ip = ip + 1;
drawnow
end
</pre><p>However the <i>drawnow</i> function slows down the speed of animation drastically. I read other related threads but those suggestions seem not to be applicable to this code, as I'm using <i>surface</i> and not updating any image or video. I wonder if anyone could help me speed up the code a little bit. Thanks a lot.</p>Mehdihttps://it.mathworks.com/matlabcentral/profile/authors/2875994-mehditag:it.mathworks.com,2005:Question/4024842018-05-25T03:18:01Z2018-05-26T19:50:53ZNumerical Differential Equation Matrix Form with Forcing Function<p>I'm trying to solve a fourth order differential equation with a forcing function t*e^(2t) with ODE45 in matrix form. The method below works fine:</p><pre class="language-matlab">F = @(t,y) [
y(2);
y(3);
y(4);
t*exp(2*t)+4*y(2)-3*y(3)+12*y(1)]
</pre><pre class="language-matlab">y0 = [0 0 0 -1/4]';
ode45(F, [0 4], y0);
</pre><p>But when I try a matrix form of the system, the forcing function returns an error for an undefined t.</p><pre class="language-matlab">A = [0 1 0 0
0 0 1 0
0 0 0 1
12 4 -3 0]
</pre><pre class="language-matlab">b = [0 0 0 -t*exp(2*t)]'
y0 = [0 0 0 -1/4]'
F = @(t, Y, A, b) A*Y+b;
</pre><pre class="language-matlab">ode45(@(t,Y) F, [0,4], y0)
</pre><p>I've used this method for undriven systems of first-order equations. Does anyone know how to modify the code to fix the error?</p>Timothy Sullivanhttps://it.mathworks.com/matlabcentral/profile/authors/12806106-timothy-sullivantag:it.mathworks.com,2005:Question/4026762018-05-26T14:51:09Z2018-05-26T19:49:57ZSubscript indices must either be real positive integers or logicals.<p>I'm trying to calculate the phase specturm, I1,Q1 are complex vectors. I get that error</p><pre class="language-matlab">ff1 = fft(I1+Q1,512);
ff2 = fft(I2+Q2,512);
</pre><pre class="language-matlab">a1 = angle(ff1);
a2 = angle(ff2);
diffangle = a1 - a2;
</pre>Ahmed Tolbahttps://it.mathworks.com/matlabcentral/profile/authors/12897258-ahmed-tolbatag:it.mathworks.com,2005:Question/4026972018-05-26T18:52:21Z2018-05-26T19:20:03ZUpdating an array elements with elements from another Array<p>Hello, Could I please get some assistance on how to update array elements with elements from another array,
For example</p><pre class="language-matlab">A = rand(10,10);
B = rand(10,10);
Result = A-B;
</pre><pre class="language-matlab">%Identifty which elements are greater than 0
SlctElemnts = Result > 0 ;
%%Update all the elements in A that is less than 0 with the element in B
% A (Result<0);
disp(A)
</pre>Zaharaddeen Hussainihttps://it.mathworks.com/matlabcentral/profile/authors/5316598-zaharaddeen-hussainitag:it.mathworks.com,2005:Question/4016732018-05-20T18:30:44Z2018-05-26T19:11:44Zrepresent differencital equation with ode45<p>i got this differential equation:</p><pre class="language-matlab">function xdot=tresorden(t,x)
</pre><pre class="language-matlab">xdot=zeros(3,1);
</pre><pre class="language-matlab">Vp=5;
</pre><pre class="language-matlab">Vi=Vp*square(2*pi*t)+5;
</pre><pre class="language-matlab">xdot(1)=x(2);
</pre><pre class="language-matlab">xdot(2)=x(3);
</pre><pre class="language-matlab">xdot(3)=6*Vi-6*x(1)-11*x(2)-6*x(3);
</pre><pre class="language-matlab">xdot=[xdot(1);xdot(2);xdot(3)];
</pre><p>how can i represent x(1)?</p>jose luis guillan suarezhttps://it.mathworks.com/matlabcentral/profile/authors/12803414-jose-luis-guillan-suareztag:it.mathworks.com,2005:Question/4026712018-05-26T13:00:40Z2018-05-26T19:11:38ZHow can I display not recognized for someone not in the database?<p>Hi everyone!I am working on real time face recognition, I have made classifier. The problem that I am having is that if someone outside the database comes in it(the code) will classify him/her inside the database. So how can I determine if someone is not in the database and display not recognized?
I am tracking face using KLT algorithm and here's the code in comment</p>Ali Subhanhttps://it.mathworks.com/matlabcentral/profile/authors/12151408-ali-subhantag:it.mathworks.com,2005:Question/4026982018-05-26T19:10:12Z2018-05-26T19:10:12ZHow do I use webread to extract data from a site over multiple pages to an Excel sheet?<p>I want to download the data from a site <a href = "http://icasualties.org/OEF/Fatalities.aspx">http://icasualties.org/OEF/Fatalities.aspx</a>
to an Excel sheet.
The site contains 3549 records of data spread over 70 pages.
How to use webread to automate this process and collect all data into one excel sheet?</p>Heshamhttps://it.mathworks.com/matlabcentral/profile/authors/806772-heshamtag:it.mathworks.com,2005:Question/4026892018-05-26T17:23:31Z2018-05-26T19:04:40Znormalization , colums, rows<p>Hi everyone,</p><p>May I know which way correct to do normalization for a matrix by colums or rows?</p><p>Thanks.</p>Dhurgham Al-karawihttps://it.mathworks.com/matlabcentral/profile/authors/6500027-dhurgham-al-karawitag:it.mathworks.com,2005:Question/4026812018-05-26T16:12:45Z2018-05-26T18:54:26Zhow do i lopping many data in one folder ?<p>I have data per hour in a folder with two different data types. I want to use the data to get one result, but the existing script can only run per hour. I want to run it directly in 1 month.I attach the data script.</p><p>can anyone guide me to lopping the data directly within 1 month?</p><p>thanks</p>Suvany Apriliahttps://it.mathworks.com/matlabcentral/profile/authors/12635338-suvany-apriliatag:it.mathworks.com,2005:Question/4018032018-05-21T17:34:25Z2018-05-26T18:49:19Zmatlab slow start after installing R2017b and configuring opengl<p>Hello. Several months ago, after upgrading from R2014a to to R2017b, I discovered that my complex graphics had poor resolution. I was informed about the changes in the graphics language and ran the opengl utility to configure the graphics options for hardware support. After doing that, I noticed that matlab started slowly, sometimes taking 2 minutes or more. I could not find a solution to the slow starts anywhere. Then, recently, after a matlab crash, matlab started very quickly, but I saw a warning that the graphics language had been updated in R2014b, and that I should configure opengl. Now, having specified opengl options for full hardware support, I find that it again starts slowly, as before. Am I doing something wrong with the configuration of my graphics language options? Below, I enclose the opengl.data results:</p><pre> Version: '3.1.0 - Build 9.17.10.4229'
Vendor: 'Intel'
Renderer: 'Intel(R) HD Graphics 3000'
RendererDriverVersion: '9.17.10.4229'
RendererDriverReleaseDate: 26-May-2015
MaxTextureSize: 8192
Visual: 'Visual 0x06, (RGBA 32 bits (8 8 8 8), Z depth 16 bits, Hardware acceleration, Double buffer, Antialias 4 samples)'
Software: 0
HardwareSupportLevel: 'full'
SupportsGraphicsSmoothing: 1
SupportsDepthPeelTransparency: 0
SupportsAlignVertexCenters: 0
Extensions: {129×1 cell}
MaxFrameBufferSize: 4096</pre><p>My computer is Lenovo T420s, with Windows 7.</p><p>Thank you for your advice and assistance.</p><p>Carl H</p>Carl Hopkinshttps://it.mathworks.com/matlabcentral/profile/authors/162547-carl-hopkinstag:it.mathworks.com,2005:Question/3338432017-04-05T17:35:27Z2018-05-26T18:39:39ZI want to calculate Region Properties Using Image Region Analyzer but i get the result cannot display summaries of variables with more than 524288 elements. My value is 2560x1920x3 uint8 . Can u help me to overcome this problem ? Thank you<p>I want to calculate Region Properties Using Image Region Analyzer but i get the result cannot display summaries of variables with more than 524288 elements. My value is 2560x1920x3 uint8 . Can u help me to overcome this problem ? Thank you</p>Sarahttps://it.mathworks.com/matlabcentral/profile/authors/8828505-saratag:it.mathworks.com,2005:Question/2833452016-05-09T15:22:31Z2018-05-26T18:07:59Zif i have two vector how to perform single crossover?<p>if i have</p><pre> p1 = [ 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 1 0 1 1]
p2 = [ 0 0 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 0 0 0 1 0 0]</pre><p>how to perform single crossover</p><pre class="language-matlab">c1 = [ 1 0 1 1 1 0 1 0 1 0 1 0 0 1 0 1 1 1 0 0 0 1 0 0]
c2 = [ 0 0 0 0 1 1 1 1 0 0 1 1 1 0 1 0 0 0 0 0 1 0 1 1]
</pre>Firas Al-Kharabshehhttps://it.mathworks.com/matlabcentral/profile/authors/7624311-firas-al-kharabshehtag:it.mathworks.com,2005:Question/4026922018-05-26T17:38:45Z2018-05-26T18:05:10ZRandperm same sequence each time you run the code<p>Is there a possibility to have each time the same random permutation when you run the code to make results comparable?</p><pre class="language-matlab">randperm(length(X))
</pre><p>I want to have the random numbers in the same order everytime the code is run.</p>Stefhttps://it.mathworks.com/matlabcentral/profile/authors/8051710-steftag:it.mathworks.com,2005:Question/4026942018-05-26T18:01:42Z2018-05-26T18:01:42ZAligning actual with target profile / rigid transform<p>Ok, I am playing around with this problem quite a while now. So far it was just fun and games, but now it's about time to put the game to bed. Maybe somebody from the community has encountered a similar problem or has a better mathematical understanding then I have.</p><p>My situation: I measure a geometric 2D-profile and I want to align the measured profile with a target profile (translation and rotation) to evaluate the deviation.</p><p>I tried to align the profiles with a rigid transform and the least squares method, which works well for certain profiles when every point of one profile has a corresponding point on the other profile. But in my case the target profile is just a section of the measured profile with less points. Also possible outliers might be a problem.</p><p>What is the correct approach to this problem? Do I have to leave out the rotation?
I really cannot wrap my head around it. A little push in the right direction is needed.</p><p>Thanks in advance.
Attached a picture (red one is the target profile)</p>Kaindlhttps://it.mathworks.com/matlabcentral/profile/authors/8540115-kaindltag:it.mathworks.com,2005:Question/4025902018-05-25T16:04:05Z2018-05-26T17:54:20ZHow to store data from pushbutton within a nested function?<p>I feel like this is a super easy fix, but I cannot seem to figure out how to store a variable within a nested function...Here is my function so far</p><p>data_labels and step_labels are variable length cell arrays, while input_labels is a variable length array of sequential numbers between 1 & 10.</p><p>My issue is I can get my pushbutton to correctly output 'vals' via the display, but when I try storing vals outside of the push_call function, I cannot seem to get it to overwrite the zeros array.</p><pre class="language-matlab">function vals = MyGUI2(data_labels,input_labels,step_labels)
</pre><pre class="language-matlab">num_inputs = max(input_labels) - min(input_labels) +1;
num_steps = max(size(step_labels));
</pre><pre class="language-matlab">components_index = step_labels;
h.table = uitable('units', 'pixels', 'position',...
[10, 10, num_inputs*110, num_steps*40],...
'columnname', data_labels,...
'columnformat', {'logical'}, 'ColumnEditable', true,...
'rowname', step_labels,...
'data', true(numel(components_index),num_inputs));
</pre><pre class="language-matlab">% Creates a pushbutton to save data
vals = zeros(num_steps,num_inputs);
</pre><pre class="language-matlab">h.push = uicontrol('style','pushbutton','units','pixels',...
'position',[num_inputs*200/4,50,80,40],'string','Done',...
'callback',@push_call);
function vals = push_call(varargin)
vals = get(h.table,'data'); % determines which boxes are checked
</pre><pre> disp(vals) % just displaying your values that you have selected
end
% need to strore vals somehow!</pre><pre class="language-matlab">end
</pre><p>Thanks in advance :)</p>Hunter Stevensonhttps://it.mathworks.com/matlabcentral/profile/authors/7574010-hunter-stevensontag:it.mathworks.com,2005:Question/4026902018-05-26T17:29:09Z2018-05-26T17:50:44Zdiff function for "Differentiate symbolic expression or function" vs "Differences and Approximate Derivatives"<p>I am trying to use diff as the first option but it keeps doing the second. How can I make it differentiate instead of doing the differences one? They both have the same function caller.</p>Sarah Weatherlyhttps://it.mathworks.com/matlabcentral/profile/authors/7633471-sarah-weatherly