https://se.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2017-11-25T00:10:46Ztag:se.mathworks.com,2005:Question/3690522017-11-24T17:05:25Z2017-11-25T00:10:46ZRetaining values for a Matrix!<p>I have a matrix A. A has dimensions (10,100). I also have 10 different text files.Each text file loads 100 binary values.I have written a script which loads a text file,copies all the 100 binary values in A and displays A.I want A to retain all the rows for 10 text file loads serially.I am loading the text files serially i.e I take one text file, load it, copy its data into A,then again replace the previous text file with the new one, run the script again , load new values in A...till all the text files are loaded. How can I achieve this? To save all the previous data in a matrix even after running the same script with new inputs multiple times
Help appreciated!
Waiting..</p>Hrishikesh lelehttps://se.mathworks.com/matlabcentral/profile/authors/9033861-hrishikesh-leletag:se.mathworks.com,2005:Question/3689462017-11-24T03:43:38Z2017-11-25T00:10:32ZHow can I create a loop that can take the mean of each variable for 130 variables.<p>I have 130 variables named "ff_Threshold1_020" through "ff_Threshold1_150" these variables are 250 x 250 double. I would like to take the mean of each variable twice - to receive a single value for each of the 130 variables. How can I create a loop to do this?
Please be detailed, I am a complete noob at matlab and programming.</p>Lorenzo Lamberthttps://se.mathworks.com/matlabcentral/profile/authors/8603640-lorenzo-lamberttag:se.mathworks.com,2005:Question/3690932017-11-24T21:18:26Z2017-11-25T00:08:20ZHow to access variables from another function?<p>I want to accesses a variable in one function in another function.
Here's part of the code:</p><pre class="language-matlab">function initial(hObject, eventdata, handles, varargin)
nproduto = randi([1,5],1,1)
end
</pre><pre class="language-matlab">function calcular(hObject, eventdata, handles)
set(handles.preco, 'String', nproduto)
end
</pre><p>It gives an error that doesn't recognize produto in the last function.</p>Renato Pereirahttps://se.mathworks.com/matlabcentral/profile/authors/9143071-renato-pereiratag:se.mathworks.com,2005:Question/3691112017-11-25T00:07:08Z2017-11-25T00:07:08ZWhile calculating power spectral density it is showing an error , vector lengths must be same<p>I am calculating power spectral density of voltage and time values from an excel sheet of 2 columns and 9689 rows.
while plotting the graph it is throwing an error
"Error using plot
Vectors must be the same length.
Error in lpf (line 19)
plot(fc,Nc)"
Please help me out. I am attaching the code file in the above attachment.</p>dark lionhttps://se.mathworks.com/matlabcentral/profile/authors/10866847-dark-liontag:se.mathworks.com,2005:Question/3690762017-11-24T19:01:20Z2017-11-25T00:02:26ZHaving A problem with surfc<p>X = 0:10; %This a range from 1 to 100 cities in MA
Y = 0:25; %In the year 2012
%1 2 3 4 5 6 7 8 9 10
Z = [27 630 72 12 32 26 253 567 203 28;
315 132 16 113 642 38 560 19 5 87;
2076 1992 58 243 352 185 218 15 28 32;
543 618 37 13 53 5647 490 48 21 11;
742 450 30 1082 4 148 12 50 1196 566;
92 201 84 58 189 704 394 64 8 68;
102 193 113 48 50 267 66 27 44 74;
2808 460 177 254 20 66 52 460 33 14;
27 16 53 302 95 93 174 35 22 17;
1122 306 956 1195 682 2 544 1213 938 152];
Xi = 0:.1:10;
Yi = 0:.1:10;
[Xi, Yi] = meshgrid(Xi, Yi);
surfc(Xi, Yi);</p>Jasmine Andradehttps://se.mathworks.com/matlabcentral/profile/authors/9474692-jasmine-andradetag:se.mathworks.com,2005:Question/3687842017-11-23T10:02:07Z2017-11-24T23:58:37ZMinimize error of linear regression by changing input x-vector<p>Hi!</p><p>I´ve got data for heating use (kWh)per day over a year for a house in a cold climate as well as the average temperature per day of the same year. The space heating dependency of the outside
temperature can be described by a simple linear regression of kWh in relation to outside temperature as shown below.</p><img src = "/matlabcentral/answers/uploaded_files/95804/Example.png"><p>But since the building has got a thermal inertia the temperature of yesterday is also affecting the heating needs of today. Therefore it is more correct to describe the space heating need as dependent of the <i>weighted temperature t</i>. This can be described by the following equation:</p><p>t=w*tc + (1-w)*ty</p><p>Where
t: weighted temperature</p><p>tc:Outdoor temperature of current day</p><p>ty: Outdoor temperature of day before current day</p><p>w: the weight factor describing the thermal inertia of the house, which i want to calculate.</p><p>The sum of squared error of the linear regression should be mostly dependent of the thermal inertia of the house (but also in random variations of heat and tap water use by the inhabitants). By minimizing the SSE by changing the weighted temperature (vector) by variating w the most correct weight factor (w) should be found.</p><p>To clarify I want to "calculate" the thermal inertia of the building, expressed by the thermal weight factor (w). I am therefore not so interested in fitting the best curve to the data, but instead "fit" the best data to the linear negative correlation line of temperatuer and kWh (by changing the original temperature to weighted temperature).</p><p>I have been trying to achieve this by using fminbnd as following</p><pre> tw = @(w) ((w*tc)+(1-w)*ty);
errorfun = @(w) "Sum of squared error of the linear regression of" (tw,kWh);
wOptimal = fminbnd(errorfun,0,1);
(tw,tc,ty and kWh are vectors)</pre><p>But i struggle to find a function which returns the "Sum of squared error of the linear regression of" two vectors, and i´m also not sure if i´m using fminbnd the right way.</p><p>Does anyone have any idea how this can be written?</p><p>Example data is attached.</p><p>/Carl</p>Jotonhttps://se.mathworks.com/matlabcentral/profile/authors/5858502-jotontag:se.mathworks.com,2005:Question/3691002017-11-24T22:14:16Z2017-11-24T23:53:53ZPlotting stations from different dates<p>Hi,
I need to plot this salinity (S) data so that station 1 shows 3 dates on the graph and then a new subplot shows station 2 with the same dates.</p>Amelia Newmanhttps://se.mathworks.com/matlabcentral/profile/authors/9142513-amelia-newmantag:se.mathworks.com,2005:Question/3690772017-11-24T19:04:18Z2017-11-24T23:53:51Zworking out acceleration from 2 matrices- HELP<p>I have 2 matrices: velocity and time</p><p>velocity = [0,56.40,97.23,136.25,226.16,403.86,440.44,1265.23]</p><p>time = [0,10,15,20,30,59,62,125]</p><p>it asks to work out acceleration</p><p>This is what i have done:</p><p>clc;</p><p>clear all;</p><p>close all;</p><p>time = [0,10,15,20,30,59,62,125];</p><p>velocity = [0,56.40,97.23,136.25,226.16,403.86,440.44,1265.23];</p><p>for i=1:length(time)</p><pre> for ii=1:length(velocity)</pre><pre> for x=1:1:7
%%accelertaion = change in velocity / change in time%%
acceleration(x) = (velocity(1,(x+1))-velocity(1,x))/(time(1,(x+1))-time(1,x))</pre><pre> end</pre><pre> end</pre><p>end</p><p>So this gives me:</p><p>acceleration =
Columns 1 through 6</p><pre> 5.6400 8.1660 7.8040 8.9910 6.1276 12.1933</pre><pre class="language-matlab">Column 7
</pre><pre> 13.0919</pre><p>So my question is:
how do i put a 0 in column 1 of the acceleration matrix and shift everything else? i need 1*8 matrix.</p><p>i want to plot a graph of acceleration against time so the size of matrix needs to be the same.</p>Noman Khanhttps://se.mathworks.com/matlabcentral/profile/authors/11208010-noman-khantag:se.mathworks.com,2005:Question/3691102017-11-24T23:48:19Z2017-11-24T23:52:31ZHow to obtain image size [227 227 3]?<p>I'm currently working on using my own images in a pretrained neural network ( https://www.mathworks.com/help/nnet/ref/alexnet.html ) and it's demanding an image size of [227 227 3]. My images are 2D binary images (227x227). How can I achieve the desired size of images?</p>Anna Strashttps://se.mathworks.com/matlabcentral/profile/authors/11548713-anna-strastag:se.mathworks.com,2005:Question/3690532017-11-24T17:09:04Z2017-11-24T23:38:49ZHow do I randomly generate multiple random shapes within a given area WITHOUT overlapping?<p>Hi,
I have generated a random shape. I need to loop it over to randomly distribute such shapes within a given area WITHOUT overlapping. Area could be n by n units where n being a large integer number compared to the size of an individual shape.</p>Anuruddha Jayasuriyahttps://se.mathworks.com/matlabcentral/profile/authors/9358271-anuruddha-jayasuriyatag:se.mathworks.com,2005:Question/3691092017-11-24T23:32:37Z2017-11-24T23:32:37ZApproximating frequency with respect to time using Hilbert() is giving me very wrong/noisy graphs. Why?<p>So I've been trying to read out the frequencies of a wav file with respect to time using the code below:</p><pre> [y,fs] = audioread('C:\...\pianoCbar.wav');
y(:,1) = []; %making the sample mono
t = 0:1/fs:(length(y)-1)'/fs; %setting up time array matching smaple length
z = hilbert(y,length(y));
instfreq = fs/(2*pi)*diff(unwrap(angle(z)));
plot(t(2:end),instfreq)
xlabel('Time')
ylabel('Hz')
title('Instantaneous Frequency')</pre><p>The frequencies that are actually being played are: 261.62, 293.25, 329.28, 349.22, 391.99, 440, 493.88, and 523.25. The problem is the graphical representation of which shows a utterly wrong frequencies. The attached .png file is a shot of the current graph and the zip is the .wav file I am approximating the frequencies of. What am I doing incorrectly here? How can I get the proper, or near proper frequencies. Then, if possible, how can I readout those frequencies and their respective time?</p>Erik Randallhttps://se.mathworks.com/matlabcentral/profile/authors/8076343-erik-randalltag:se.mathworks.com,2005:Question/3691082017-11-24T23:23:46Z2017-11-24T23:34:50ZNon Coherent Binary ASK System: Problem in signal detection i.e. not getting proper BER curve <p>I have written a MATLAB code for a BASK system with non coherent detection. The data rate if 64Kbps.</p><p>1) The BER calculated in the code is not varying much with the change in SNR(dB). I have simulated the system with SNR:1-15dB, but the BER curve (which i have calculated using three different techniques) remains a straight line. So I reckon that there must be some problem in the detection process maybe improper threshold in comparator part.
2) The received bit stream obtained after the detection process is not like the one obtained with 0 noise added. As in, the bit goes to 0 each time the modulated ASK system's sin wave has a null and then back to 1.</p><p>In the detection process, I have first passed the received signal through a LPF to reduce noise, followed by rectification and then comparator (threshold defined here). There might be some problem in the comparator's code, but i cant identify it. BER values calculated by 3 methods mentioned in the code are exactly the same.
Code written below:</p><pre> clc;
clear all;
close all;</pre><p>%% ----- BASEBAND SIGNAL PARAMETERS -----%%</p><pre> D_R=64e3; %Data Rate = 64Kbps
P_D=1/D_R; %Pulse duration</pre><p>%% TRANSMITTER %%%</p><p>%% SIGNAL GENERATION %%</p><pre> bits=16; %no of bits generated at input
Input=rand(1,bits)>0.5; %bit sequence generated
Input=repmat(Input',1,4000)'; %bit sequence repeated for 64Kbps
Input=Input(:)';
t=linspace(0,bits,numel(Input));
figure('Name','Transmitted Data')
subplot(3,1,1);
plot(t,Input,'r'); </pre><p>%% CARRIER GENERATION %%</p><pre> DC=1/2;
Ao=3;
F=5;
Carrier=Ao.*sin(2*pi*F*t)+DC;
subplot(3,1,2);
plot(t,Carrier,'b');</pre><p>%% ASK MODULATION %%</p><pre> ModSig=Carrier.*Input;
subplot (3,1,3);
plot(t,ModSig);</pre><p>%% TRANSMISSION MEDIUM %%</p><p>%% ZERO NOISE</p><pre> No=0;
RxSig_1=ModSig+No;</pre><p>%% MULTIPLE AWGN</p><pre> for SNRdB_=1:1:15
RxSig_3=awgn(ModSig,SNRdB_,'measured',10);
end
L1=length(RxSig_1);
L3=length(RxSig_3); </pre><p>%% RECEIVER %%</p><p>%% LOW PASS FILTER TO REDUCE THE EFFECT OF NOISE %%</p><pre> LPF = fdesign.lowpass('Fp,Fst,Ap,Ast',5,20,1,30,100);
lowpass = design(LPF,'equiripple');
fvtool(lowpass); </pre><p>%% RECEIVED BIT STREAM WITHOUT NOISE</p><pre> % RECEIVED SIGNAL
figure ('Name','Received Bit Stream Without AWGN');
subplot (2,1,1);
plot(t,RxSig_1);</pre><pre> % COMPARATOR
for a=1:1:L1
if RxSig_1(a)==0
R1(a)=0;
else
R1(a)=1;
end
end
subplot(2,1,2)
plot(t,R1);</pre><p>%% RECEIVED BIT STREAM WITH MULTIPLE AWGN: SNR IN dB=1-15dB %%</p><pre> figure('Name','Received Signal After Multiple AWGN');
title('BASK RECEIVED SIGNAL WITH MULTIPLE AWGN');
for SNR_dB=1:1:15 </pre><pre> %% ADDING NOISE</pre><pre> RxSig3=awgn(ModSig,SNR_dB,'measured',10); </pre><pre> %% FILTERATION</pre><pre> R3F=filter(lowpass,RxSig3);
subplot(4,4,SNR_dB)
plot(t,RxSig3,'g','LineWidth',2);
hold on;
plot(t,R3F,'b');
title(['SNR: ',num2str(SNR_dB),'dB']);
ylim( [-8 8]);
end
legend('Signal with AWGN','Signal After Filteration');</pre><pre> h=1;
i=1;
j=1;
k=1;
l=1;
m=1;</pre><pre> figure('Name','RECEIVED BITS AFTER AWGN: SNR=1-15dB');
for SNR=1:1:15
snrlin=10.^(SNR./10);
RxSig_3=awgn(ModSig,SNR,'measured',10);
R3_F=filter(lowpass,RxSig_3); </pre><pre> %% RECTIFICATION %%</pre><pre> R3_R=abs(R3_F); </pre><pre> %% COMPARATOR %%</pre><pre> for Sample=1:L3
if R3_R(Sample)>1
Rx_Bits(Sample)=1;
else
Rx_Bits(Sample)=0;
end
end
subplot(5,3,SNR)
plot(t,Rx_Bits);
title(['SNR: ',num2str(SNR),'dB']);
xlim( [0 16]); </pre><p>%% %% BER %%</p><pre> %% BER 1
error=length(find(Rx_Bits~=Input)); % BER (Simulated)
cber(h)=error/64000;
h=h+1;</pre><pre> tber(i)= 0.5*erfc(.707*sqrt(snrlin)); % BER (Theoretical-ASK)
i=i+1;</pre><pre> snrdb(j)=SNR;
j=j+1; </pre><pre> %% BER 2
err(k)=0;
for u=1:64000
if (Input(u)~=Rx_Bits(u))
err(k)=err(k)+1;
end
end
ber2(k)=err(k)/64000;
k=k+1;</pre><pre> %% BER 3
[num(l),BER3(m)] = biterr(Input,Rx_Bits);
l=l+1;
m=m+1;</pre><pre> end
legend('BASK Received BITSTREAM with different AWGN');</pre><pre> %% PLOTTING CALCULATED BER
figure ('Name','System BER');
subplot(3,1,1)
semilogy(snrdb,cber,'-bo')
subplot(3,1,2)
semilogy(snrdb,ber2,'-bo')
subplot(3,1,3)
semilogy(snrdb,BER3,'-bo')
title('Calculated BER vs Eb/No in dB');</pre><pre> %% Plotting the theoretical and calculated BER
figure ('Name','Comparison B/W Theoretical & Calculated BER');
semilogy(snrdb,cber,'-bo',snrdb,tber,'-mh')
grid on
title('BER vs Eb/No or SNR in dB');
legend; </pre><p>Regards</p><p>Anum Ahmed Pirkani</p>Anum Ahmedhttps://se.mathworks.com/matlabcentral/profile/authors/9019761-anum-ahmedtag:se.mathworks.com,2005:Question/3691072017-11-24T23:22:01Z2017-11-24T23:22:01ZHow does one interactively manipulate polar plot data?<p>Although the source of my original antenna measurement data cannot be found, I have imported a set of polar plot files in the form of PNG images into <a href = "https://automeris.io/WebPlotDigitizer/">WebPlotDigitizer</a> and from it have exported CSV pairs that represent the angular and radial components of the antenna pattern into MATLAB. However, as WebPlotDigitzer's results are not identical to the original polar plots, I need to modify the values of the angular and radial components. Ideally, this would be done interactively with the mouse when working with the polar data and visually comparing the results with the PNG images.</p><p>From MATLAB Exchange, I have downloaded and experimented with the only two m-files that might offer the solution sought: "moveplot.m"; and "LineManipulator.m". However, it would appear that neither is capable of working with data displayed in a polar axes.</p><p>Which MATLAB functions would allow me to interactively modify the data displayed in the polar plot?</p><p>All suggestions will be very much appreciated.</p>Matlab Userhttps://se.mathworks.com/matlabcentral/profile/authors/2996368-matlab-usertag:se.mathworks.com,2005:Question/3691052017-11-24T23:08:14Z2017-11-24T23:15:10ZFmincon error and solver stopped prematurely?<p>Hi, I'm using Fmincon for optimization but when I try to run the script with the initial conditions that I give it, it gives me the following error after performing a single iter:</p><pre class="language-matlab">Converged to an infeasible point.
</pre><pre class="language-matlab">fmincon stopped because the size of the current search direction is less than
twice the default value of the step size tolerance but constraints are not
satisfied to within the default value of the constraint tolerance.
</pre><pre class="language-matlab"><stopping criteria details>
</pre><p>when trying to relax the restrictions the error is next after 1 iter</p><pre class="language-matlab">Local minimum found that satisfies the constraints.
</pre><pre class="language-matlab">Optimization completed because the objective function is non-decreasing in
feasible directions, to within the selected value of the optimality tolerance,
and constraints are satisfied to within the default value of the constraint tolerance.
</pre><pre class="language-matlab"><stopping criteria details>
</pre><p>Any idea why this problem???.</p>alan ghihttps://se.mathworks.com/matlabcentral/profile/authors/11601108-alan-ghitag:se.mathworks.com,2005:Question/3691042017-11-24T22:34:12Z2017-11-24T23:28:31ZFitting routine, optimization with two functions for one problem<p>Hello matlab team. I have a question to an optimization of a fitting routine. I am trying to plot data to a set of functions. The problem is that I do not know how to handle two functions for fitting one problem. At the moment I am trying to do the following with the lsqcurvefit. Data attached.</p><pre class="language-matlab">clear all;
close all;
</pre><pre class="language-matlab">%% Prepare data
% Load data
Aktor = importdata(['Aktor1.txt']);
Aktor_freq = Aktor(:,1);
Aktor_ampl = Aktor(:,2);
Aktor_phase = Aktor(:,3);
</pre><pre class="language-matlab">Re_Y = Aktor_ampl.*cos(deg2rad(Aktor_phase)); % Conductance G
Im_Y = Aktor_ampl.*sin(deg2rad(Aktor_phase)); % Susceptance B
</pre><pre class="language-matlab">plot(Re_Y,Im_Y,'ok','LineWidth',1.5); % Show data in complex plain
hold all
</pre><pre class="language-matlab">% Define start parameters
C_0 = 3.8182e-08;
R_m = 8.0856e+03;
L_m = 15.3030;
C_m = 1.0271e-09;
tan_d = 0.02;
</pre><pre class="language-matlab">x_data = Aktor_freq; % x-values
y_data = Aktor_ampl; % y-values
</pre><pre class="language-matlab">% Show start parameters
y_0 = (2*pi*x_data*C_0*(i+tan_d))+1./(R_m+i*(2*pi*x_data*L_m-1./(2*pi*x_data*C_m)));
plot(real(y_0),imag(y_0),'r','LineWidth',1.5);
</pre><pre class="language-matlab">%% Generate Fit
% [C_0, R_m, L_m, C_m, tan_d];
x0 = [1, 1, 1, 1, 1]; % Relative altering
lb = [1/10, 1/10, 1/10, 1/10, 1/10]; % Lower bound
ub = [1*10, 1*10, 1*10, 1*10, 1*10]; % Upper bound
</pre><pre class="language-matlab">Fun = @(x,xdata) abs((2*pi*xdata*C_0*x(1)*(i+tan_d*x(5)))+1./(x(2)*R_m+i*(2*pi*xdata*L_m*x(3)-1./(2*pi*xdata*C_m*x(4)))));
options = optimset('TolX',1e-20,'TolFun',1e-20);
x = lsqcurvefit(Fun,x0,x_data,y_data,lb,ub,options);
</pre><pre class="language-matlab">% Show fitted data
y_fit1 = (2*pi*x_data*C_0*x(1)*(i+tan_d*x(5)))+1./(x(2)*R_m+i*(2*pi*x_data*L_m*x(3)-1./(2*pi*x_data*C_m*x(4))));
plot(real(y_fit1),imag(y_fit1),'b','LineWidth',1.5);
xlabel('real part')
ylabel('imaginary part')
</pre><p>You can see. I am using only one function with five parameters that I fit relativ to its start value. The fit function is not that good. Showing the data in the complex plain is required. The curves does not match properly. I get a very nice result if I change tan_d = 0.05;</p><p>I would like to change the routine. I have two different functions.</p><pre class="language-matlab">w = 2*pi*Aktor_freq;
</pre><p>The real part is defined by:</p><pre class="language-matlab">Fun1 = R_m./(R_m^2 + (w*L_m - 1./(w*C_m)).^2) + w*tan_d*C_0 == Re_Y
</pre><p>The imaginary part is defined by:</p><pre class="language-matlab">Fun2 = (-w*L_m + 1./(w*C_m))./(R_m^2 + (w*L_m - 1./(w*C_m)).^2) + w*C_0 == Im_Y
</pre><p>So I show you the figures of the imaginary and the real part.</p><p><b>Real</b></p><p>tan_d = 0.2</p><img src = "/matlabcentral/answers/uploaded_files/96031/real.jpg"><p><b>Imaginary</b></p><img src = "/matlabcentral/answers/uploaded_files/96030/imaginary.jpg"><p>The imaginary part seems to fit quite nice but the real part doesn't hit the spot. I found out that the global peak of the real part and the peak of Fun1 has to be almost equal.</p><p>Maybe I can somehow try to give the points around the peak of the real part a higher weight. So the fit converges to it more then to the other points. The main idea is to find the parameters so that the fit matches the ellipse of the data in the complex plain.</p><p>Is there any way to solve this problem?. Imagine how to handle both functions for a fitting procedure is out of my level. I appreciate any advice. I tried working with the genetic algorithm but with no succes.</p><p>Regards Henrik</p>Henrik Schädlichhttps://se.mathworks.com/matlabcentral/profile/authors/9590169-henrik-schadlichtag:se.mathworks.com,2005:Question/3691062017-11-24T23:08:48Z2017-11-24T23:08:48Zdc motor constant current simulink<p>DC motor features: 5HP, 250V, 1700 rpm and I want to constant current 21A and motor speed 1500 rpm. how to design control simulink ?</p>kvnc krnzhttps://se.mathworks.com/matlabcentral/profile/authors/11601107-kvnc-krnztag:se.mathworks.com,2005:Question/1622572014-11-11T16:29:53Z2017-11-24T23:07:50ZProblem with 'Patch' graphics in 2014b - Splits in two along diagonal<p>I'm using 'Patch' to replace the boxes in box plots to change the colour etc. Code is:</p><pre class="language-matlab">h = findobj(gca,'Tag','Box');
for x=1:length(h)
boxShade=patch(get(h(x),'XData'),get(h(x),'YData'), colours(x,:), 'linestyle', 'none');
uistack(boxShade,'bottom');
end
delete(h);
</pre><p>This worked fine until I updated to 2014b where now the Patches appear to split in two along the diagonal, with the median in front of one half and behind the other. Example cut from exported pdf:</p><img src = "/matlabcentral/answers/uploaded_files/20887/Ave_1.jpg"><p>I am using the painters renderer as I'm outputting vector pdfs.
Any ideas? I've seen some other talk that it's a bug from intersecting lines in a patch but there are no intersections here I believe as it's just a simple rectangle?</p><p>Any help greatly appreciated!
David</p>Davidhttps://se.mathworks.com/matlabcentral/profile/authors/2749754-davidtag:se.mathworks.com,2005:Question/3691022017-11-24T22:19:44Z2017-11-24T23:03:17ZHow to edit variable in 2017a?<p>Hi</p><p>I recently upgraded from 2011a to 2017a, and have a big problem to deal with.</p><p>Is there any way to edit "Variables" directly in MATLAB R2017a?</p><p>In MATLAB R2011a (or R2013a), "Vabiables" view was like this</p><img src = "/matlabcentral/answers/uploaded_files/96022/temp2.png"><p>Here the data is accessed like an excel file, and each element is modifiable.</p><p>However, it changed like this in MATLAB R2017a.</p><img src = "/matlabcentral/answers/uploaded_files/96023/temp.png"><p>Now I can see all the data files, but there are two major differences. I cannot 1) modify each element and 2) copy&past it into excel.</p><p>Is there any way that I can get back to the formatting of R2011/2013a? Although I can get around this issue, it creates unnecessary steps and additional time to do such simple tasks.</p><p>Best,</p><p>Richard</p>Richard Johhttps://se.mathworks.com/matlabcentral/profile/authors/8188133-richard-johtag:se.mathworks.com,2005:Question/1544412014-09-11T23:44:55Z2017-11-24T23:00:19ZHow can I adjust matlab for a high resolution monitor?<p>Hi,</p><p>I just started using a 2560x1440 monitor and all the fonts in matlab became very small. Font section in preferences seems to only give control over current folder and command window but not the menu. Is there a way to adjust this? I'm using matlab in Linux.</p><p>Thanks</p>NThttps://se.mathworks.com/matlabcentral/profile/authors/5490544-nttag:se.mathworks.com,2005:Question/3689302017-11-23T22:51:52Z2017-11-24T22:55:15Zrow of all 8’s <p>Suppose O=ones(n)
Now how can I insert a row of all 8’s between
rows (n-3) and (n-2) of matrix O
and insert a column of all 8’s
between columns 1 and 2 of matrix )</p>Chung Dihttps://se.mathworks.com/matlabcentral/profile/authors/11484915-chung-ditag:se.mathworks.com,2005:Question/3690642017-11-24T18:00:40Z2017-11-24T22:52:07ZHow can I convert this switch case to if else while maintaining the same results in the graph. HELP!<p>Here is the code:</p><pre class="language-matlab">N=100;
x=zeros(1,N);
y=x;
for a=2:N
c=randi([0,2]);
switch c
case 0
x(a)=0.5*x(a-1);
y(a)=0.5*y(a-1);
case 1
x(a)=0.5*x(a-1)+.25;
y(a)=0.5*y(a-1)+sqrt(3)/4;
case 2
x(a)=0.5*x(a-1)+.5;
y(a)=0.5*y(a-1);
end
end
plot(x,y,'.')
</pre>Reni Llupahttps://se.mathworks.com/matlabcentral/profile/authors/11068062-reni-llupatag:se.mathworks.com,2005:Question/3691032017-11-24T22:24:55Z2017-11-24T22:30:37Zhow can i find a value that is bigger than 95% of the values in a given vector<p>I have a vector A=[X1; X2; X3; ...Xn] and i would like to find a value that is bigger than 95% of the components of this vector. How can i do this?</p>Dominique Gorissenhttps://se.mathworks.com/matlabcentral/profile/authors/8884441-dominique-gorissentag:se.mathworks.com,2005:Question/3690992017-11-24T22:13:24Z2017-11-24T22:19:42ZAssignment has more non-singleton rhs dimensions than non-singleton subscripts Error in Antenna Toolbox when subtracting antenna.polygons<p>I am trying to generate random antenna patches by cutting out small rectangles from a antenna.Rectangle. However, after a random number of iterations, I get the following error message:</p><pre class="language-matlab">Assignment has more non-singleton rhs dimensions than non-singleton subscripts
</pre><pre class="language-matlab">Error in em.internal.findBoundary
Error in em.internal.extractGeometryFromMesh
Error in em.MeshGeometry/buildGeometryFromBoolean
Error in antenna.Shape/calculateFillsAndHolesFromBoolean (line 803)
[Geometry,GD,NS,SF,G] = buildGeometryFromBoolean(obj,B,O,true);
Error in antenna.Shape/updateBoolean (line 793)
[Geometry,G] = calculateFillsAndHolesFromBoolean(obj,B,O);
Error in antenna.Shape/updateObject (line 737)
updateBoolean(newpoly);
Error in - (line 453)
updateObject(obj,poly1,O,poly2);
Error in generate_antenna_from_array (line 57)
antenna_layer = antenna_layer - h1;
</pre><p>Below my function:
antenna_pattern is a logical array e.g. 30x30 where each field set to 0 corresponds to a piece of the antenna_rectangle to be cut out.</p><pre> function [antenna_layer, Fx, Fy] = generate_antenna_from_array(antenna_pattern)</pre><pre> f = 5.795e9;
c = physconst('LightSpeed');
lambda = c/f; % in millimeters wavelength</pre><pre> % Antenna Layer
L = 66e-3; % length antenna (X direction) Old values = 26e-3
W = 50.5e-3; % width antennda (Y direction) Old values = 35.5e-3</pre><pre> % resolution
x_res = size(antenna_pattern,2);
y_res = size(antenna_pattern,1);</pre><pre> x_unit = L/x_res;
y_unit = W/y_res;</pre><pre> antenna_layer = antenna.Rectangle('Length',L,'Width',W,'NumPoints',4);</pre><pre> % cut out parts set to 0
for row = 1:y_res
for col = 1:x_res
if antenna_pattern(row,col) == 0
center_x = -L/2 + (col-1)*x_unit + x_unit/2;
center_y = +W/2 - (row-1)*y_unit - y_unit/2;
h1 = antenna.Rectangle( 'Length',x_unit,'Width',y_unit,...
'NumPoints',4,...
'Center',[center_x, center_y] );
% cut rectangle h1 out of antenna_layer
antenna_layer = antenna_layer - h1;</pre><pre> end
end
end
end</pre><p>Is there an error in the Antenna Toolbox, i.e. in Antenna.Polygon that causes this issue?</p><p>Please help me resolve this issue.</p>Systemtechnikerhttps://se.mathworks.com/matlabcentral/profile/authors/5188450-systemtechnikertag:se.mathworks.com,2005:Question/3691012017-11-24T22:14:50Z2017-11-24T22:14:50ZBalance root-mean-square in audio clips<p>I read in a paper that audio fragments were energy balanced "so that the root-mean-square power value was equal across clips". How does one balance the RMS power value across audio clips? Thanks.</p>Tahariet Sharonhttps://se.mathworks.com/matlabcentral/profile/authors/5406172-tahariet-sharontag:se.mathworks.com,2005:Question/3690952017-11-24T21:41:34Z2017-11-24T22:08:58ZHaving a Hard Time with C Coder!! Help Please<p>Hi All,</p><p>I am currently working on some code which extracts features from accelerometer data, and produces a 0/1 output. I am happy with the code in matlab, and I would now like to export this to C.</p><p>Although the code gets a readiness score of 5, It flags up all sorts of errors when I try to compile it... and as someone with little experience with C, I'm finding it very herd to rectify the issue(s).</p><p>For simplistic sake, I have attached the function, test bed and also the XYZ inputs.</p><p>I would be massively grateful if someone could give me a hand with this.</p><p>Thanks,</p>richard finchhttps://se.mathworks.com/matlabcentral/profile/authors/11367699-richard-finchtag:se.mathworks.com,2005:Question/3690982017-11-24T21:57:08Z2017-11-24T21:57:08ZOn Off Keying optical system Matlab code <p>I want to Write a Matlab code to simulate OOK optical system, then I obtain the BER versus the Q-factor</p>Abdelwahab Fawzyhttps://se.mathworks.com/matlabcentral/profile/authors/6561729-abdelwahab-fawzytag:se.mathworks.com,2005:Question/3690962017-11-24T21:47:59Z2017-11-24T21:56:04ZUndefined function or variable 'polyshape'.<p>I don't know why I have this problem,I was just trying to create a polygon.</p>khoa tranhttps://se.mathworks.com/matlabcentral/profile/authors/6388522-khoa-trantag:se.mathworks.com,2005:Question/3690852017-11-24T20:12:04Z2017-11-24T21:54:09ZNeed help with: Error using "mex"<p>I am trying to run a script which requires <b>mex</b>. Earlier It was generating the below error</p><pre class="language-matlab">Error using mex
No supported compiler or SDK was found. For options, visit
http://www.mathworks.com/support/compilers/R2015a/win64.html.
</pre><pre class="language-matlab">Error in faster_rcnn_build (line 13)
mex -O -outdir bin ...
</pre><p>Above error got resolved after installing "Microsoft Windows SDK 7.1". I also had to restore the compiler as mentioned in this <a href = "https://in.mathworks.com/matlabcentral/answers/97006-why-do-i-get-errors-with-compiling-even-after-i-have-installed-the-supported-compilers-microsoft-vis">link</a> because of some issue. Now I am stuck with this new error.</p><pre class="language-matlab">Error using mex
nms_mex.cpp
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\intrin.h(26) : fatal
error C1083: Cannot open include file: 'ammintrin.h': No such file or directory
</pre>Atinesh Singhhttps://se.mathworks.com/matlabcentral/profile/authors/8382894-atinesh-singhtag:se.mathworks.com,2005:Question/3690862017-11-24T20:12:10Z2017-11-24T21:53:05ZI am using Macbook air (macOS Sierra) and Matlab-R2016a<p>I am new to Matlab and I am unable to understand why this error is coming up and how to solve it</p><p>>>gcc --version</p><p>Undefined function or variable 'gcc'.</p><p>>> mex -setup</p><p>Error using mex</p><p>No supported compiler or SDK was found</p>Sravya Dumapalahttps://se.mathworks.com/matlabcentral/profile/authors/8681115-sravya-dumapalatag:se.mathworks.com,2005:Question/3689132017-11-23T20:32:28Z2017-11-24T21:49:32ZMatlab add markers to bar of slider uicontrol<p>I would like to add some markers to a slider bar (see the figure below). I tried to achieve the desired result with a axis on top of a slider uicontrol. Unfortunately the axis are always one layer below the uicontrol slider. Therefore I put the axes into a panel which I position above the slider. This leads to the problem that the slider thumb cannot be moved anymore when its position is behind the panel.</p><p>What is the best way to draw markers into the slider bar and at the same time make the slider thumb visible for all thumb positions?</p><pre class="language-matlab">f = figure;
</pre><pre class="language-matlab">sld = uicontrol( 'Parent', f, ...
'Tag', 'sldTime', ...
'UserData', zeros(1,0), ...
'Style', 'slider', ...
'Units', 'normalized', ...
'Position', [0.01, 0.1, 0.8, 0.1],...
'FontSize', 10, ...
'BackgroundColor', [1 1 1], ...
'Enable', 'on');
</pre><pre class="language-matlab">panel = uipanel('Parent', f, 'Position', [0.05, 0.1, 0.7, 0.1], 'BackgroundColor', [1, 1, 1]);
</pre><pre class="language-matlab">ax = axes('Parent', panel, 'Units', 'normalized', 'Position', [0, 0.1, 1, 1]);
</pre><pre class="language-matlab">h = plot(ax, [0, 0], [0, 1]);
hold(ax, 'on');
h2 = plot(ax, [1, 1], [0, 1]);
axis(ax, 'state', 'equal');
</pre><pre class="language-matlab">ax.Visible = 'off';
</pre><img src = "/matlabcentral/answers/uploaded_files/95903/oX086.png">invarianthttps://se.mathworks.com/matlabcentral/profile/authors/3146946-invarianttag:se.mathworks.com,2005:Question/3690972017-11-24T21:49:28Z2017-11-24T21:49:28ZPlotting BER vs Q factor <p>In Wireless communication, there is one common formula which relates the Q factor and BER for any type of network</p><p>BER=1/2 erfc (Q/ √ 2 )</p><p>I want to plot this relation between BER and Q factor in MATLAB.</p>Abdelwahab Fawzyhttps://se.mathworks.com/matlabcentral/profile/authors/6561729-abdelwahab-fawzytag:se.mathworks.com,2005:Question/3690922017-11-24T21:10:37Z2017-11-24T21:35:36ZHow to take the convolution of two functions<p>I'm trying to find the convolution of a x=rectangular pulse function and an f=inverse laplace transform function(found by doing ilaplace) however when I type the code y=conv(x,f) it throws these errors:</p><pre class="language-matlab">Error using conv2
Invalid data type. First and second arguments must be numeric or logical.
</pre><pre class="language-matlab">Error in conv (line #)
c = conv2(a(:),b(:),shape);
</pre><p>I've looked up many examples to try to fix this but so far none have worked.Any advice would be appreciated.</p>JLhttps://se.mathworks.com/matlabcentral/profile/authors/11422521-jltag:se.mathworks.com,2005:Question/3674192017-11-16T14:32:26Z2017-11-24T21:35:18ZGet Values from other m.file via dropdown<p>In one m.file is a simple gui with a popupmenu with 4 options (C25,C35,C45,C55);
In the second m.file is:</p><pre class="language-matlab">%C25
Rm=500;
Rp=600;
</pre><pre class="language-matlab">%C35
Rm=800;
Rp=900;
</pre><pre class="language-matlab">%C45
Rm=1000;
Rp=1100;
</pre><pre class="language-matlab">%C55
Rm=1200;
Rp=1300;
</pre><p>Now i need help: If i pick in the popupmenu C25, it should search "C25" in the second sheet and bring me the Values Rm=500 and Rp=600 to the First m.file. I dont know, how it works and i really need help, cause I am a matlab Rookie.</p><p>Thanks for the help.
Best Regards AJ</p>Ajith Ravichandranhttps://se.mathworks.com/matlabcentral/profile/authors/8048998-ajith-ravichandrantag:se.mathworks.com,2005:Question/3650002017-11-03T20:08:03Z2017-11-24T21:31:43ZHow to include a "time delay" in a simscape custom code [Matlab 2015a]<p>I created a SimScape custom component that implements an externally commanded brake on my rotational degree of freedom. I modified the rotational friction block to respond to an external signal who applies the friction torque instantaneously.</p><p>Now, I would like to apply this braking friction gradually within a certain time. In Matlab2017b, I believe that it is fairly straightforward to do with the new events feature. However we are currently locked-up to 2015a, so I am trying to find a way to do something similar.</p><p>Anyone has a tip?</p><p>In summary,
when A becomes active, I want to ramp the friction from 0 to Max in a specified time TAU.</p><p>Thanks</p>Francois Godinhttps://se.mathworks.com/matlabcentral/profile/authors/4422305-francois-godintag:se.mathworks.com,2005:Question/3671562017-11-15T09:33:52Z2017-11-24T21:31:01ZForm a Cumulative sum matrix<pre class="language-matlab">S= 10x1300
R=10x1300
z1= S1+R1 x1300
z2=S1+R1+R1+S2+R2 x1300
z3=S1+R1+R1+S2+R2+R2+S3+R3 x1300
.
.
.
z10=S1+R1+R1+S2+R2+R2+S3+R3+.. +R9+S10+R10+R10 x 1300
Result: Form z, a 10x1300 matrix
</pre><p>S & R is a 10x1300 matrix of random numbers</p><p>First row of matrix z= First row of S + first row of R</p><p>Second row of matrix z= First row of S + first row of R + first row of R + second row of S + second row of R + second row of R</p><p>Each addition adds Previous row of R and the next row of S and R</p>Joseph Leehttps://se.mathworks.com/matlabcentral/profile/authors/11106352-joseph-leetag:se.mathworks.com,2005:Question/3690912017-11-24T21:07:14Z2017-11-24T21:23:15Zwhat this name for this block please <p>name the block in this pic</p>abdallah hamdyhttps://se.mathworks.com/matlabcentral/profile/authors/11244277-abdallah-hamdytag:se.mathworks.com,2005:Question/3689332017-11-23T23:59:09Z2017-11-24T21:21:21ZDistribution of Random variables<p>I am trying distribution of a random
variable X=Y1+Y2+……+Yn where Y1,Y2…,Yn
are i.i.d. uniformly distributed random
variables? What can you conclude from the
resulting PDF?</p>Chung Dihttps://se.mathworks.com/matlabcentral/profile/authors/11484915-chung-ditag:se.mathworks.com,2005:Question/3690872017-11-24T20:17:29Z2017-11-24T21:16:36ZArduino erros using Matlab. (Use Matlab like Monitor Serial)<p>Hi,
I trying to control one Arduino system and read their output data, just like the monitor serial from the Arduino IDE.
I read a little about it, but I only find how to set some outputs signals and/or read some digital outputs.
I trying something but it always comes to this message and I can only read the first message that would come in the serial monitor.
'Warning: Unsuccessful read: A timeout occurred before the Terminator was reached..'</p><pre class="language-matlab">s = serial('COM11')
set(s,'BaudRate', 115200)
fopen(s)
out = fscanf(s)
z=1;
while (z==1)
dat = fscanf(s);
fwrite(s,1);
fscanf(s);
end
</pre><p>It's one way that the Matlab works like the serial monitor, I mean, that I can read e write information instantly? I like to use Matlab because sometimes I would like to use some loops and it would be impossible to do automatic in serial monitor from Arduino IDE.</p><p>Thanks, everybody.</p>Szillathttps://se.mathworks.com/matlabcentral/profile/authors/5311345-szillattag:se.mathworks.com,2005:Question/3652762017-11-05T22:27:34Z2017-11-24T21:13:44ZExample for the difference between SWT and DWT<p>Hi,there.</p><p>I am looking for the understandable example to show the difference between DWT and SWT.</p><p>In Wavelet toolbox user's guide 3-66, it is written that "the DWT is not a time-invariant transform. This means that, even with periodic signal extension, the DWT of a translated version of a signal X is not, in general, the translated version of the DWT of X."</p><p>What does it mean?</p><p>Is there good example to show the difference?</p>Macy Shttps://se.mathworks.com/matlabcentral/profile/authors/9212984-macy-stag:se.mathworks.com,2005:Question/3690652017-11-24T18:01:04Z2017-11-24T21:10:40ZFROM array of objects TO array of object's property<p>Hi every one! my problem is the following:</p><p>I have a class "Actor" that as a "Name" and "Age" properties.
Then I have an N-size array of them a(1:N) = Actor();</p><p>now I want to create a cell array of all the names of the Actors in the in the Actors array.</p><p>Is there a neat fast way of doing this?!</p>Francisco Diashttps://se.mathworks.com/matlabcentral/profile/authors/10031885-francisco-diastag:se.mathworks.com,2005:Question/3605212017-10-10T02:49:59Z2017-11-24T20:54:00ZCan anyone help me with good reference books on Discrete Wavelet Transform?<p>I am working on EEG signals. For feature extraction I need to use DWT. It's urgent.
Thanks.</p>Md Monirul Islamhttps://se.mathworks.com/matlabcentral/profile/authors/9830173-md-monirul-islamtag:se.mathworks.com,2005:Question/3690242017-11-24T13:57:37Z2017-11-24T20:53:58ZHow to do background subtraction between two images to find the ROI?<p>I took two frames,I want to subtract the background so that I can work on the region which I am Interested(Human). I have attached two pictures.</p><img src = "/matlabcentral/answers/uploaded_files/95986/23896972_10208584138000721_837893471_o.png"><p>is the image of a road.The image with a human is this</p><img src = "/matlabcentral/answers/uploaded_files/95987/23897359_10208584136600686_1613314999_o.png"><p>Please help me with the code.I want to separate the human and crop the human region.</p><p>Thank you</p>Jawad Siddiquehttps://se.mathworks.com/matlabcentral/profile/authors/9396365-jawad-siddiquetag:se.mathworks.com,2005:Question/1067272013-11-19T09:18:38Z2017-11-24T20:50:01ZMatlab requires 15 minutes to start up<p>Hi,</p><p>The last few days, my matlab have been extremely slow. Starting matlab takes around 15 minutes. I have tried to read other posts on this topic, but nothing of what have been suggested have worked.</p><p>I don't understand a lot of the output of the timing logs. Any help would be highly appreciated.</p><p>I have both Matlab 32 and 64 bit installed. The timing logs of the respective versions are as follows.</p><p>MATLAB R2012a, 64 bit:</p><pre class="language-matlab">Opening timing log C:\Users\ulfjakob\AppData\Local\Temp\timing_log.8532 ..
MATLAB Startup Performance Metrics (In Seconds)
</pre><pre class="language-matlab">total item gap description
=====================================
0.00 0.00 0.00 MATLAB script
0.54 0.54 0.00 main
21.06 20.30 0.21 LM Startup
21.06 0.00 0.01 splash
21.83 0.45 0.32 InitSunVM
23.52 1.63 0.05 PostVMInit
23.52 2.14 0.32 mljInit
75.77 52.25 0.00 StartDesktop
75.77 54.39 0.32 Java initialization
75.79 0.02 0.00 hgInitialize
75.86 0.01 0.06 psParser
76.02 0.05 0.11 cachepath
77.02 0.88 0.13 matlabpath
78.88 3.10 75.77 Init Desktop
552.70 0.00 475.68 SettingsConstructo
552.73 476.71 0.00 matlabrc
=====================================
Items shown account for 100.4% of total startup time [TIMER: 2 MHz]
</pre><p>MATLAB R2013a, 32 bit:</p><pre class="language-matlab">Opening timing log C:\Users\ulfjakob\AppData\Local\Temp\timing_log.1468 ..
MATLAB Startup Performance Metrics (In Seconds)
</pre><pre class="language-matlab">total item gap description
=====================================
0.00 0.00 0.00 MATLAB script
0.27 0.27 0.00 main
20.60 20.31 0.01 LM Startup
20.61 0.00 0.01 splash
21.55 0.50 0.44 InitSunVM
22.64 1.04 0.05 PostVMInit
22.64 1.59 0.44 mljInit
74.96 52.32 0.00 StartDesktop
74.96 53.91 0.44 Java initialization
74.97 0.02 0.00 hgInitialize
75.13 0.01 0.15 psParser
75.29 0.06 0.10 cachepath
76.90 1.21 0.39 matlabpath
81.22 6.26 74.96 Init Desktop
532.49 457.20 0.00 matlabrc
=====================================
Items shown account for 101.0% of total startup time [TIMER: 2 MHz]
</pre>Ulf Jakobhttps://se.mathworks.com/matlabcentral/profile/authors/3606194-ulf-jakobtag:se.mathworks.com,2005:Question/3690902017-11-24T20:48:22Z2017-11-24T20:48:22ZError using pdepe (line 248) Unexpected output of PDEFUN. For this problem PDEFUN must return three column vectors of length 6.<p>function myco</p><p>x=linspace(0,1,100);</p><p>t=linspace(0,4,10);</p><p>m=0;</p><p>sol=pdepe(m, @biopde, @bioic, @biobc,x,t);</p><p>ne = sol(:,:,1);</p><p>ns = sol(:,:,2);</p><p>nd = sol(:,:,3);</p><p>uu = sol(:,:,4);</p><p>mm = sol(:,:,5);</p><p>phi= sol(:,:,6);</p><p>subplot(2,3,1)
surf(x,t,ne)
title('En')
xlabel('D')
ylabel('T')</p><p>subplot(2,3,2)
surf(x,t,ns)
title('St')
xlabel('D')
ylabel('T')</p><p>subplot(2,3,3)
surf(x,t,nd)
title('Is')
xlabel('D')
ylabel('T')</p><p>subplot(2,3,4)
surf(x,t,uu)
title('Ce')
xlabel('D')
ylabel('T')</p><p>subplot(2,3,5)
surf(x,t,mm)
title('My')
xlabel('D')
ylabel('T')</p><p>subplot(2,3,6)
surf(x,t,phi)
title('Ox')
xlabel('D')
ylabel('T')</p><p>end</p><p>function [c,f,s] = biopde(x,t,u,DuDx)</p><pre> ce = 4;</pre><pre> cs = 125; </pre><pre> lambdaphi = 1;</pre><pre> lambda0 = 1;</pre><pre> Dphi = 1;</pre><pre> dk = 1;</pre><pre> ds = 1;</pre><pre> de = 1;</pre><pre> lambdau = 1; </pre><pre> Du = 1;</pre><pre> Dm = 1;</pre><pre> lambdam = 1;</pre><pre> phimax = 1;</pre><pre> H=1;</pre><p>c=[1;1;1;1;1;1];</p><p>s=[de <b>u(1)*H *(u(5)-ce)- dk</b>(phimax-u(6))*u(1);</p><pre> -ds*u(2)*H*(u(5)-cs)- dk*(phimax-u(6))*u(2);</pre><pre> ds*u(2)*H*(u(5)-cs)- dk*(phimax-u(6))*u(2); </pre><pre> lambdau*u(4); lambdam*u(4);</pre><pre> lambda0 *(u(1) + u(2))- lambdaphi* u(3)* u(6)];</pre><p>f=[0;</p><pre> 0;</pre><pre> 0;</pre><pre> Du .*(DuDx) .*u(4);</pre><pre> Dm .*(DuDx) .* u(5);</pre><pre> Dphi .*(DuDx) .*u(6)];</pre><p>end</p><p>function u0 = bioic(x);</p><p>u0 = [0.1;0.1;0.1;1.0;1.0;0.1];</p><p>end</p><p>function [pl,ql,pr,qr] = biobc(xl,ul,xr,ur,t)</p><p>pl = ul;</p><p>ql = [0;0;0;0];</p><p>pr = ur;</p><p>qr = [0;0;0;0];</p><p>end</p>FATUMAH ATUHAIREhttps://se.mathworks.com/matlabcentral/profile/authors/11238099-fatumah-atuhairetag:se.mathworks.com,2005:Question/3690882017-11-24T20:19:10Z2017-11-24T20:48:11Zcreate one to one function between a rows of 2 vectors<p>I'm fairly new to Matlab and I'm looking to create a function that assigns the first n numbers in their binary form to a random number between 0 and 1. This is what I've got so far but it isnt really working.</p><pre class="language-matlab">n=3
d2b = de2bi(0:2^n-1)
randnos = rand(2^n,1)
f=@(x) randnos(find(d2b(x,:)==x));
f(d2b(1,:))
</pre><p>Any help would be greatly appreciated!</p>Alden Robertsonhttps://se.mathworks.com/matlabcentral/profile/authors/11510262-alden-robertsontag:se.mathworks.com,2005:Question/3690892017-11-24T20:41:40Z2017-11-24T20:41:40ZHaving trouble to run FOC model in Embedded coder<p>Hello, I am using F28377s and trying to run the PMSM FOC model. And I am getting some error about bit number and data conversion. I have tried to use the Data conversion block and also tried with "Dataoverride OFF" but it didn't work.
I observed that only the model with SCI block is showing error.
It would be very helpful if you could give me a solution.</p>Animesh Anikhttps://se.mathworks.com/matlabcentral/profile/authors/11283140-animesh-aniktag:se.mathworks.com,2005:Question/3690782017-11-24T19:23:00Z2017-11-24T20:35:08ZHow to initlialize the 'RotationMatrices' property in a cameraParameters Object?<p>I want to generate / initialize my own cameraParamters object with the 'RotationMatrices' Property.</p><p>I'm getting this error:</p><p><b>'RotationMatrices' is not a recognized parameter. For a list of valid name-value pair arguments, see the documentation for this
function.</b></p><pre class="language-matlab">cPara = cameraParameters('IntrinsicMatrix',W','RotationMatrices',R,'TranslationVectors',T);
</pre><p>I try to convert it to a structure, add the field and then reconvert back but to no avail.</p><p>I'm doing this to use with the bundleAdjustment function. Can someone tell me how to go about this? Thanks</p>BLEARGH BUNYhttps://se.mathworks.com/matlabcentral/profile/authors/9973641-bleargh-bunytag:se.mathworks.com,2005:Question/3676222017-11-17T13:26:43Z2017-11-24T20:34:03ZAre the filters used for wavelet decomposition the same for each level ?<p>i'm using the wavelet transform decomposition (daubechies 4) and i want to know are the filters used for the decomposition the same for each level ?</p>afefhttps://se.mathworks.com/matlabcentral/profile/authors/9902982-afeftag:se.mathworks.com,2005:Question/3683792017-11-21T13:39:42Z2017-11-24T20:14:28ZArray multiplication along certain dimension? <p>I have a 4-D array with dimensions A = A1 x A2 x A3 x N and a vector with dimensions V = 1 x N. I would like to multiply each element in the array A with vector V along fourth dimension and take a sum along the same dimension to form a matrix B = A1 x A2 x A3. Currently I am using a loop to achieve this, but is there any faster method to achieve the same result? Thanks!</p><pre class="language-matlab">A1 = 3;
A2 = 3;
A3 = 3;
N = 10;
</pre><pre class="language-matlab">A = ones(A1, A2, A3, N);
V = ones(1, N);
B = NaN(A1, A2, A3);
</pre><pre class="language-matlab">for i = 1:A1
for j = 1:A2
for k = 1:A3
B(i,j,k) = squeeze(A(i,j,k,:))' * V';
end
end
end
</pre>Visa Suomihttps://se.mathworks.com/matlabcentral/profile/authors/3902389-visa-suomitag:se.mathworks.com,2005:Question/3675032017-11-16T22:04:19Z2017-11-24T20:11:34ZDifferent length character in graphical interface set(hObject)<p>Hi,</p><p>I want to define the text options (String) of a GUI matalb dropbox menu directly in the code, not using the toolbox changing the String field. I also want to use special characters such as _ and strings that have a different length.</p><p>This is the code I use in the 2017 version</p><pre> test=["A_";"B";"C"];
set(hObject,'String',test)</pre><p>But unfortunately I need to use R2014a and " " are not usable in this version, is there another way to display the characters ? or another method to set the string ?</p><p>Thanks
Benjamin</p>Benjamin LECLERCQhttps://se.mathworks.com/matlabcentral/profile/authors/10956809-benjamin-leclercq