https://www.mathworks.com/matlabcentral/answers/questionsMATLAB Answers β New Questions2019-08-20T18:29:50Ztag:www.mathworks.com,2005:Question/4769122019-08-20T18:29:50Z2019-08-20T18:29:50ZProblem generating exe file using Matlab CompilerI am making project with Pluto SDR and Matlab. Downloaded support package from Analog Devices and everything worked okay until i wanted to make exe standalone file with Matlab Compiler. At first i was geting messages about undefined superclass for example comm.plutoradio.rx and after adding p files additionaly errors kept changing until i added almost every p file and now i get this new message that i titled matlab undefined. It is in line 54 where i log sampled data from rx of pluto [data]=rx(); Is there a way to go around this. I tried to do restoredefaultpath and then get new error message about sdrrx not defined and couldnt run my project anymore. C is my primary partition, but i installed matlab on D:. This project is in Matlab/bin folder.
Thank you, Aleksandaraleksandar vujichttps://www.mathworks.com/matlabcentral/profile/authors/15945057-aleksandar-vujictag:www.mathworks.com,2005:Question/4769012019-08-20T17:53:07Z2019-08-20T18:29:26ZHow to write a legend in latex formatNpc=2;
legend('\Sigma_{i=1}^{Npc} x^\prime_i','Total L_w','Noise');
In the below figure's legend, how do we need to include a variable Npc.
Kalasagarreddi Kottakotahttps://www.mathworks.com/matlabcentral/profile/authors/10818389-kalasagarreddi-kottakotatag:www.mathworks.com,2005:Question/4769112019-08-20T18:23:56Z2019-08-20T18:23:56ZHow can I limit the size of the output signal from deconvolution using deconvwnr?I want to deconvolve a signal with a point spread function to retrieve a "ground truth" signal. I know that the ground truth is roughly Gaussian and should be 7x7 pixels.
This works when I do deconvolution without noise. However, when I add noise I get this weird periodic semi-gaussian signal that is the same length as the point spread function (47 pixels).
Is it possible to restrict the size of the output to be a 7x7 image?Benjamin Brennerhttps://www.mathworks.com/matlabcentral/profile/authors/8322393-benjamin-brennertag:www.mathworks.com,2005:Question/4769102019-08-20T18:20:22Z2019-08-20T18:23:45ZHow to adapt C-language S-function to Opal-RT?I am working with Opal-RT (with Matlab R2011a) to implement a Microgrid controller using a S-function in C language. The simulation works very well in Simulink environment, where I am using .mexw32 for compilation. However, the following error apears when I try to build the model into the target (i.e. Opal RT):
ntox86-g++-3.3.5: sfunc_teste2.o: No such file or directory
The name of the .c file that my S-function calls is sfunc_teste2.c . The full error is in the attached file. It seems that Opal-RT cannot find the .c files, even though they are in the same directory of all my project file. How can I send all dependant .c/.h of my S-function to Opal-RT? Is it possible to use S-function without using .tlc files in Opal-RT?Daniela Yamashitahttps://www.mathworks.com/matlabcentral/profile/authors/14673261-daniela-yamashitatag:www.mathworks.com,2005:Question/4769052019-08-20T18:00:07Z2019-08-20T18:17:31ZSave values in each iterationHello !!!
Good Morning.
I have the following code:
----------------------------------------------------------------------
clc; clear; close all; short format
Ccl = 21; % Number of column elements
gene = 5; % Number of times the column is generated
for wl = 1: gen
for kk = 1: Ccl
minx1 = 0.2028;
maxx1 = 1.0141;
xx1 = (maxx1-minx1). * rand (1,1) + minx1;
dx1 (kk) = xx1;
dx1 = dx1 ';
end
end
-------------------------------------------------- -----------------------
This code randomly generates a vector of a column with 21 lines (21 X 1), but
I would like to keep the values of the 5 columns, this case the variable "gen" has 5
Normally the value of the "gen" variable can be 500.
Greetings and thanks.Ricardo Gutierrezhttps://www.mathworks.com/matlabcentral/profile/authors/8586559-ricardo-gutierreztag:www.mathworks.com,2005:Question/4769092019-08-20T18:15:11Z2019-08-20T18:15:11ZHow to extract specific images from a library of images?I have a folder which has 600 images, the images are named as 10000, 10001, 10002,... I have an excel file which has the information about the image number of interest. For example, I want image number 0,3,8,12,16,224 etc to be extracted from this library. How do I go about executing that? Any help would be appreciated.
oshawcolehttps://www.mathworks.com/matlabcentral/profile/authors/9137511-oshawcoletag:www.mathworks.com,2005:Question/4769082019-08-20T18:09:29Z2019-08-20T18:10:58ZAvoid turning plot when on a figure Hello!
I need to plot x and y coordinates over a figure representing a map, which will be displayed at a viewport on the rightop of the figure.
However, when I use the code below, it works, but y coordinates of the points are flipped. Using only the first three lines of the code places the figure properly; using the code without the image function places the points in the correct position. When I run the whole code, y-axis flips and y-coordinates are plotted flipped. I tried set(gca,'Ydir','reverse'), but it did not work.
Any help?
Thanks.
ha2=axes('position',[0.75, 0.55, .22,.42,]); % position of the viewport
image(mapabase,'XData',[-49.7 -48.7],'YData',[1.12 1.67]) %image workin as a map
hold on
for k=1:1:qtde_psgns
plot(navios_cel{k}(:,4),navios_cel{k}(:,3),'.','markers',5); %coordinates of several surveys
end
grid on
hold off
xlim ([-49.7 -48.7])
ylim ([1.12 1.67])Diego Fonsecahttps://www.mathworks.com/matlabcentral/profile/authors/15651016-diego-fonsecatag:www.mathworks.com,2005:Question/4768972019-08-20T17:30:26Z2019-08-20T18:07:28ZHow to remove/rename part of a file name in a loop?Hi,
I am trying to rename 50,000 images that have an incorrect file name. They are all .tif files with a name similar to "Hoverdofeightnosleevetriggered000002.T000.D000.P000.H000.LA" and should be named like this "Hoverdofeightnosleevetriggered000001A". The files start at 0 and increase from there. Everyother photo is called A or B. Can someone please help me rename them in a loop?
I have looked online and can't seem to find a code that will work.
Thanks in advance! Monique Emburyhttps://www.mathworks.com/matlabcentral/profile/authors/14608780-monique-emburytag:www.mathworks.com,2005:Question/4769072019-08-20T18:06:56Z2019-08-20T18:06:56Z Input ports (1, Action) of 'Component_cooling_circuit_bat_without_embedded_function/Subsystem1/If Action Subsystem' are involved in the loop?I am trying to simulate a closed loop cooling system using simulink but facing this error continously.
If anyone can help me with this would be of great help?
I have uploded the file,if anyone can please run it and share the trouble shooting measures willbe of greta help.
I ahve uploded the mat variable file for initialization parameters of the modelAdithttps://www.mathworks.com/matlabcentral/profile/authors/13747156-adittag:www.mathworks.com,2005:Question/4768832019-08-20T15:23:54Z2019-08-20T18:01:11Zlinearly spacing a nX1 matrix Hi!
I have an nx1 matrix. I want to linearly divide the value in each row into 16 columns thus giving me a nx16 linearly spaced matrix.
For a little example let us say I have a=[45; 50] now I want to creat a 2x4 matrix such that the values in consecutive clolumns are linearly spaced and their sum is equal to 45. Could someone help on this one please?
Z.khanhttps://www.mathworks.com/matlabcentral/profile/authors/15988861-z-khantag:www.mathworks.com,2005:Question/2743862016-03-19T11:03:23Z2019-08-20T17:57:55Zimshow and plot not displaying when using opticalFlowHi,
Following the optical flow examples, the code below is behaving in an odd way. If I only use imshow on the image it will refresh in real-time (i.e comment out the plot command), however if I try to plot the optical flow vectors, I will only get the very last frame displayed once the loop has completed. Could anyone shed any light on this?
vidDevice = imaq.VideoDevice('winvideo', 1);
optical = opticalFlowHS;
nFrames = 0;
while (nFrames<100)
nFrames = nFrames + 1;
rgbData = step(vidDevice);
grey = rgb2gray(rgbData);
optFlow = estimateFlow(optical,grey);
imshow(rgbData);
hold on
plot(optFlow, 'DecimationFactor',[5 5],'ScaleFactor',25);
hold off
end
release(vidDevice);
Many thanksPaul Greshamhttps://www.mathworks.com/matlabcentral/profile/authors/6661540-paul-greshamtag:www.mathworks.com,2005:Question/4768342019-08-20T09:50:41Z2019-08-20T17:57:17ZHow to create new file in another folder?I have got 2 files namely DCM file and text file.I have to compare the parameters in text file and Dcm file and if those parameters presented, then I have to copy the parameters from DCM file to another new file. I have already written the code in such a way it will do this. But I have create the new file in another folder . How can I do this?nagasai thumatihttps://www.mathworks.com/matlabcentral/profile/authors/13849900-nagasai-thumatitag:www.mathworks.com,2005:Question/4769032019-08-20T17:56:11Z2019-08-20T17:56:11ZHow do I perform an integration on a two-dimensional surface of scatttered data?I have measured data in two dimensions, not on a uniform grid. I want to perform the surface integral over the two dimensions, to get a smooth 2D surface function that I can evaluate at any input (x, y), which may be beyond the original measurement space, so smoothness and sensible extrapolation are desirable features of the integrated surface.
I have used 'scatteredInterpolant' function to obtain the surface of the original data, and then used 1-dimensional numerical integration in each dimension to create the appearance of a surface, but this is not a function F(x,y). John Woodhttps://www.mathworks.com/matlabcentral/profile/authors/9117416-john-woodtag:www.mathworks.com,2005:Question/4769022019-08-20T17:56:07Z2019-08-20T17:56:07ZHow to output voltage on myDAQ How to send 5 volts to breadboard with myDAQ for a second than delay for a second then send 5 volts etc...?
I can connect the myDAQ and create a session. s = daq.createSession('ni')
I have two National instruments toolboxes for Matlab and I have looked through many of its reccomended code and none of it is recognised by matlab. Christopher Younghttps://www.mathworks.com/matlabcentral/profile/authors/15718940-christopher-youngtag:www.mathworks.com,2005:Question/4768952019-08-20T16:54:55Z2019-08-20T17:53:14Zhi, I have a time series data,I want to find first standard deviation array and second standard deviation array,using a standard deviation window,but I am getting errors.Please help meSilpa Khttps://www.mathworks.com/matlabcentral/profile/authors/15760628-silpa-ktag:www.mathworks.com,2005:Question/4768992019-08-20T17:44:22Z2019-08-20T17:49:36ZHow to combine fill figures?Hi,
does anybody know how to combine "fill" graphs, instead of just plots, scatter...?
Cheers!Franziska Thamannhttps://www.mathworks.com/matlabcentral/profile/authors/15045770-franziska-thamanntag:www.mathworks.com,2005:Question/4768822019-08-20T15:23:37Z2019-08-20T17:47:24ZSaving Data In A For Loop Into An ArrayThis seems like a basic question, but I can't seem to figure it out.
I have data for multiple spirals and I want all the x,y and z co-ordinates for each spiral in seperate arrays. I cannot preallocate because I am not aware of the size before running the code.
Would really appreciate any help on how to save my co-ordinates for each spiral in seperate arrays. The code is pasted below
clc; clear; close all
spirals = (1:10:61);
dy = max(spirals);
indent = linspace(-255+dy, 255-dy,4);
num = 1:1:7;
cla
hold on
layerheight = [1 2 4 5];
for columns=1:4
for rows = 1:length(spirals)
center = -250 + (spirals(rows))*num(rows);
gap=layerheight(columns);
d=layerheight(columns);
r = spirals(rows);
z=(linspace(0,d,10000));
t=(40*pi/gap)*z;
x=round(r*cos(t)+center);
y=round(r*sin(t)+ indent(columns));
plot3(x,y,z,'o','MarkerSize',2)
% for counter = 1:length(z)
% rowdata(counter) = [x(rows) y(rows) z(counter)]; %this is how I thought of saving the data, but it doesn't work
% end
end
end
hold off
xlim([-255 255])
ylim([-255 255])
zlim([0 5])
grid on
xlabel('\it Increasing Radius \rightarrow')
ylabel('\it Increasing Layer Height \leftarrow')Hans123https://www.mathworks.com/matlabcentral/profile/authors/11890683-hans123tag:www.mathworks.com,2005:Question/4769002019-08-20T17:45:54Z2019-08-20T17:45:54ZCan matlab R2018a be used to control a raspberry pi 3B+ with the Support Package for Raspberry Pi Hardware? (Linux)Is it possible? There is no option displaying model 3B+. What should I do?
Italo Caliarihttps://www.mathworks.com/matlabcentral/profile/authors/3916307-italo-caliaritag:www.mathworks.com,2005:Question/4765042019-08-17T11:56:45Z2019-08-20T17:42:37ZSimulate obstacles in audio filesHi, I extracted data from a stereo wav file, I would like to simulate an obstacle between first and second vector column (Left and Right of the audio file) so that I can recreate the effect of having two microphones next to each side of a basket ball, as an example.
Hope I have been clear enough.
Thank you very much for your helpSophia Cioninihttps://www.mathworks.com/matlabcentral/profile/authors/15216336-sophia-cioninitag:www.mathworks.com,2005:Question/4768962019-08-20T16:58:59Z2019-08-20T17:40:31ZHow to find frequency contents in this signal below?Abhishek Nayakhttps://www.mathworks.com/matlabcentral/profile/authors/8475686-abhishek-nayaktag:www.mathworks.com,2005:Question/4768982019-08-20T17:34:25Z2019-08-20T17:34:25ZData Cursors on Line Plot With Spectrogram Subplot There seems to be a bug in the behavior of data cursors when both a line plot and spectrogram plot are used in the same figure window.
After creating a subplot containing a spectrogram, the data cursors for the line plot will show the x value, a time value, and the colorbar value.
clear
close all
clc
fs = 10e9;
t = (0:1/fs:250e-9);
y = sin(2*pi*500e6*t + 20*cos(2*pi*10e6*t));
subplot(2,1,1)
plot(t,y)
subplot(2,1,2)
spectrogram(y,128,64,128,fs)
I believe this bug also applies to all versions that use the new figure window styles. Kyle Younghttps://www.mathworks.com/matlabcentral/profile/authors/13610027-kyle-youngtag:www.mathworks.com,2005:Question/4768922019-08-20T16:31:51Z2019-08-20T17:34:17Zgenerate more random numbersHi everyone, when i try to generate more 100 million random sample, I memory issue with matlab.
Is there a way to generate more than 100 million samples? JLhttps://www.mathworks.com/matlabcentral/profile/authors/4943828-jltag:www.mathworks.com,2005:Question/3737902017-11-02T04:00:00Z2019-08-20T17:32:55ZWhy do I get an "Initialization commands cannot be evaluated" error upon model update with the Signal Builder block in R2016b?Using a Signal Builder block in R2016b, I am able to import signals from a MAT-file which stores a Dataset logged after simulation. However, when I update the model (Ctrl+D), I get the following error:
ERROR: Error in 'signalBuilderEx/Signal Builder': Initialization commands cannot be evaluated.
Caused by:
In an assignment A(:) = B, the number of elements in A and B must be the same.
What is the reason for this error?MathWorks Support Teamhttps://www.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:www.mathworks.com,2005:Question/3885702018-03-14T04:00:00Z2019-08-20T17:32:16ZHow can I change the temp directory the MATLAB installer uses?I am installing MATLAB but the installer cannot run to completion because my /tmp folder is not large enough. Is there anyway I can bypass using /tmp or switch the directory?
Β
MathWorks Support Teamhttps://www.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:www.mathworks.com,2005:Question/4765902019-08-18T14:49:22Z2019-08-20T17:21:37Z ERROR came as "Index exceeds matrix dimensions".%% When I incorporate 3 eqns, ERROR came as "Index exceeds matrix dimensions".
%%Here I have initial condition f=[0 0 0 ], BC: gl=[coswt t t], gr =[0 0 0 ].
What next?
Here is my trial:
H=10;R=5;Pr=1;G1=5;G2=5;Kc=1;Sc=0.22;wt=pi/2;Q=H-(R/Pr);
xl=0; xr=5; % x domain [xl,xr]
J = 10; % J: number of division for x
dx = (xr-xl)/ J; % dx: mesh size
tf = 01; % final simulation time
Nt = 100; % Nt: number of time steps
dt = tf/Nt;
mu = dt/(dx)^2;
% Evaluate the initial conditions
x = xl : dx : xr; % generate the grid point
% f(1:J+1) since array index starts from 1
f1 = 0;f2 = 0;f3 = 0; %%%I.C
% store the solution at all grid points for all time steps
u = zeros(J+1,Nt);
v = zeros(J+1,Nt);
w = zeros(J+1,Nt);
U=[u; v; w];
% Find the approximate solution at each time step
for n = 1:Nt
t = n*dt; % current time
% boundary condition at left side
gl = [cos(wt); t; t];
% boundary condition at right side
gr = [0; 0; 0];
if n==1 % first time step
for j=2:J % interior nodes
u(j,n) = (1+dt*Q)*f1(j) + dt*(G1*f2(j)+G2*f3(j))+mu*(f1(j+1)-2*f1(j)+f1(j-1));
v(j,n) = (1+dt*Q)*f2(j) + (mu/Pr)*(f2(j+1)-2*f2(j)+f2(j-1));
w(j,n) = (1-dt*Kc)*f3(j) + (mu/Sc)*(f3(j+1)-2*f3(j)+f3(j-1));
U=[u(j,n) v(j,n) w(j,n)];
end
U(1,n) = gl; % the left-end point
U(J+1,n) = gr; % the right-end point
else
for j=2:J % interior nodes
u(j,n)= (1+dt*Q)*u(j,n-1)+ dt*(G1*v(j,n-1)+G2*w(j,n-1))+ mu*(u(j+1,n-1)-2*u(j,n-1)+u(j-1,n-1));
v(j,n)= (1+dt*Q)*v(j,n-1)+ (mu/Pr)*(v(j+1,n-1)-2*v(j,n-1)+v(j-1,n-1));
w(j,n)= (1+dt*Q)*w(j,n-1)+ (mu/Sc)*(w(j+1,n-1)-2*w(j,n-1)+w(j-1,n-1));
U=[u(j,n) v(j,n) w(j,n)];
end
U(1,n) = gl; % the left-end point
U(J+1,n) = gr; % the right-end point
end
end
% Plot the results
tt = dt : dt : Nt*dt;
figure(1)
plot(x,u)
hold onMINATI PATRAhttps://www.mathworks.com/matlabcentral/profile/authors/12692023-minati-patratag:www.mathworks.com,2005:Question/4768902019-08-20T16:28:18Z2019-08-20T17:19:15ZStore results of for loop in matrixab=[X01(:) X02(:) a(:) m(:) b(:)];
Countcell=zeros(1, length(ab))
for i=1:length(ab)
X=[(ab(i,1)+(0:(ab(i,3)/dx):ab(i,3))*1),ab(i,2)]
Y=(ab(i,4).*X)+ab(i,5)
ncol=fix(X./CS)+1;
ncol=[ncol].';
nrow=fix(Y./CS)+1
nrow=[nrow].';
Ncell=[ncol, nrow]
Countcell=Ncell(i)
end
I am trying to store all the results of a for loop into one matrix. At each iteration, the result is an (n by 2) matrix. I cant use cell2mat because these matrices have different lengths. I have tried to pre-allocate, but without success.Romeo Akarahttps://www.mathworks.com/matlabcentral/profile/authors/15191153-romeo-akaratag:www.mathworks.com,2005:Question/4768172019-08-20T08:49:43Z2019-08-20T17:15:13ZFrom Euler Angle to Angle between 2 vectorsHi
I need the angle between two rigid bodies. Each has a local right handed 3D coordinate system, while the z axis is pointing at the direction of the body (bones in my case).
So I want the angle between the z axes. I don't know the length of the vectors but what my software is giving me are the euler angles.
I used acos(cos(alpha)*cos(betha)) to get to the angle, which is fine but does not work for small angles.
Now i have a task where i expect the angle to go from 0 to + 60 and then again to 0 and -60. But what happens is that the angles does not get smaller then 5Β°/-5Β° and then makes a jump. I have read that the issue is how acos & cos is computed and that i should use atan2d(norm(cross(u,v)),dot(u,v)); But i don't know how to apply that since i dont have the vectors, I only got the angles. To get to the vectors will take me a lot more computation time and I really don't want to do that. Is there another way?
Thanks,
SimonaSimona Pernischovahttps://www.mathworks.com/matlabcentral/profile/authors/7706469-simona-pernischovatag:www.mathworks.com,2005:Question/4768392019-08-20T11:23:35Z2019-08-20T17:11:12ZFinding TP, TN, FP, FN using histc. First Input must be a real non-sparse numeric array (error)I am finding TP, TN, FP, FN (confusion matrix) of predicted and actual image. smapImg is the predicted/output image and gtImg is the actual/ground truth image.
TP = histc(smapImg(gtImg), 0:255);
FP = histc(smapImg(~gtImg), 0:255);
FN = histc(~smapImg(gtImg), 0:255);
TN = histc(~smapImg(~gtImg), 0:255);
I am getting this error "First Input must be a real non-sparse numeric array" while computing FN and TN, while TP and FP are computing correctely. Please help.Nataliyahttps://www.mathworks.com/matlabcentral/profile/authors/5953637-nataliyatag:www.mathworks.com,2005:Question/4768942019-08-20T16:52:40Z2019-08-20T17:04:24ZImporting csv with strings and texts without losing columnsI want to write a script that can import a csv file at each iteration of a loop, so that I can withdraw data for each file. The number of rows and columns are varying between each file and they all have both text and numbers at varying locations.
I've tried using readtable like so:
readtable('23-Jul2019_001.csv', 'Delimiter', ',', 'ReadVariableNames', false);
But the result is a variable that is 32333x2, when it is supposed to be 1884x252. When i manually import by clicking on "import data" I get the right amount of columns and rows, and I can generate a script from this. But the script seems to be specific to that file, so it doesn't seem to be flexible enough to import several different data sets.
I also need the first two columns to be categorical or text. And the delimiter is commas.
Any advice?
erik frognerhttps://www.mathworks.com/matlabcentral/profile/authors/13883136-erik-frognertag:www.mathworks.com,2005:Question/4767182019-08-19T15:47:46Z2019-08-20T16:53:24ZPlot temperature variations using colored contours similar to 'surf' option for 3D object.I have a finite difference mesh of a 3D object having approximately 2000 nodes. I also have temperature variation data at different time steps for each node after simulation. What command should I use to plot this temperature variation for that 3D object as well as the animation of temperature variation in the object from 0-10 time steps?
Is the problem understandable?
Please Help.JAYASHREE PALhttps://www.mathworks.com/matlabcentral/profile/authors/7925236-jayashree-paltag:www.mathworks.com,2005:Question/4767642019-08-19T22:55:40Z2019-08-20T16:52:49Zhow to solve matrix differential equationhi,
I' m trying to solve this differential equation for education purposes but I'm having difficulty to solve it.
does someone know a simple way to solve it?
π β πΜ = ππ£ β (πΎπ + πΎπ‘) β π
I attached a pdf where you can find all the information about the program.
thank you very much.riccardo carrierihttps://www.mathworks.com/matlabcentral/profile/authors/12306088-riccardo-carrieritag:www.mathworks.com,2005:Question/4768552019-08-20T12:40:08Z2019-08-20T16:44:21ZHow to round up components of a matrix to 1Hello friends, I have the following problem: I want to round up the highest values of a 3 by 532 matrix to 1. Meaning if I have a matrix of y =
0.818655843258541 0.381356605388963 0.286089112378312
-0.0340005479718328 0.0773489731425248 -0.0465565535336793
-0.0390004172496434 0.852323726720712 0.337561811800249
I want y matrix highest value to become (1)
1 0 0
0 0 0
0 1 1
I used the following Code: y = round(y);. The Problem with this code comes when row 3 colume 3 result is
0
0
0
Can anybody help me? That would be awesome:)Christopher Onuohahttps://www.mathworks.com/matlabcentral/profile/authors/11171378-christopher-onuohatag:www.mathworks.com,2005:Question/4768932019-08-20T16:44:14Z2019-08-20T16:44:14ZDC/DC converterHello, I'm new to simscape, I'm building tramway model with fuel cell supercapacitor and battery, right now i have problem with DC/DC converter, on one side i have current source that represents the dynamics of how my tramway works, on the other side there is supercapacitor that needs to charge when tramway starts moving and discharge during braking, i want to know is there any simple solution for DC/DC converter that works on principle of conservation of energy. Usc*Isc=Ubus*Ibus - Ibus is known and Ubus = 600V how to implement this in simscape? How to control the I of supercapacitor?Jakub Sliwinskihttps://www.mathworks.com/matlabcentral/profile/authors/15721726-jakub-sliwinskitag:www.mathworks.com,2005:Question/637872013-02-17T13:01:18Z2019-08-20T16:41:01Zimage steganography using RGB image in matlabI was working on image steganography of lsb substitution using RGB image.I couldn't able to figure out what's wrong in the code. It is not showing an error.But,the answer is different while retrieving and codes are :
Embbeding code:
clc
c = imread('pout.tif');
c=imresize(c,[64 64],'nearest');
message = 'image';
message = strtrim(message);
m = length(message) * 8;
AsciiCode = uint8(messag e);
binaryString = transpose(dec2bin(AsciiCode,8));
binaryString = binaryString(:);
N = length(binaryString);
b = zeros(N,1);
for k = 1:N
if(binaryString(k) == '1')
b(k) = 1;
else
b(k) = 0;
end
end
s = c;
height = size(c,1);
width = size(c,2);
k = 1;
for i = 1 : height
for j = 1 : width
LSB = mod(double(c(i,j)), 2);
if (k>m || LSB == b(k))
s(i,j) = c(i,j);
else
if(LSB == 1)
s(i,j) = (c(i,j) - 1);
else
s(i,j) = (c(i,j) + 1);
end
k = k + 1;
end
end
end
imwrite(s,'msgimage.tif');
imshow(c)
retrieving_code:
clc
s = imread('msgimage.bmp');
height = size(s,1);
width = size(s,2);
m = 64;
k = 1;
for i = 1 : height
for j = 1 : width
if (k <= m)
b(k) = mod(double(s(i,j)),2);
k = k + 1;
end
end
end
binaryVector = b;
binValues = [ 128 64 32 16 8 4 2 1 ];
binaryVector = binaryVector(:);
if mod(length(binaryVector),8) ~= 0
error('Length of binary vector must be a multiple of 8.');
end
binMatrix = reshape(binaryVector,8,8);
textString = char(binValues*binMatrix);
disp(textString);
help please.
prasanthhttps://www.mathworks.com/matlabcentral/profile/authors/4076408-prasanthtag:www.mathworks.com,2005:Question/4733942019-07-25T08:36:34Z2019-08-20T16:40:15ZCell Array Dynamic Size
Any thoughts would be helpful!XChttps://www.mathworks.com/matlabcentral/profile/authors/8400855-xctag:www.mathworks.com,2005:Question/4768912019-08-20T16:30:45Z2019-08-20T16:30:45ZPhasor plot representation sinusoidal Hi,
I'm trying to plot in a phasor rapresentation current data acquired from CTs in a real 3p circuit.
I have access to the data in a txt file, currently I'm just plotting the three sinusoidal components in time domain, but I'd like to have a phasor representation to see theirphase shift.
Is there an easy why to do it? I've tried compass but it gives weird results. Thanks.
MarcoMarco Bosihttps://www.mathworks.com/matlabcentral/profile/authors/8221871-marco-bositag:www.mathworks.com,2005:Question/4768892019-08-20T16:24:10Z2019-08-20T16:27:55ZHow to pass Options as an argument in quadprogDear all,
In MATLAB help, the quadprog() function can be used with either
x = quadprog(H,f)
x = quadprog(H,f,A,b,Aeq,beq,lb,ub,x0,options)
I would like to pass "options" as an argument without pass other arguments like "A,b,Aeq,beq,lb,ub,x0". Is it possible to call the function in a way like this "x = quadprog(H,f,options)"?
Thank you in advance.Yize Wanghttps://www.mathworks.com/matlabcentral/profile/authors/13624223-yize-wangtag:www.mathworks.com,2005:Question/4758502019-08-12T16:08:27Z2019-08-20T16:23:01ZSOC Constraint in cplexmiqcpHi,
I am trying to solve a problem which has a second-order cone constraint as follow
The code that I have is:
Qij= cell(1,J);
for j=1:J
Q=zeros(I*J+3*J+J*K+1+I+J+I*J);
Q((j-1)*I+1:j*I,(j-1)*I+1:j*I)=diag(xinom);
Q(I*J+j,I*J+J+j)=-1;
Qij{j}=Q;
end
%l
l=[zeros(I*J+3*J+J*K+1+I,J);Gamma*eye(J);kron(eye(J),ones(I,1))];
%r
r=zeros(J,1);
The problem is with 'l', when it is zero, it works fine but when I put it as above it says that Q is not positive semi-definite.
Can anyone help me?
ThanksNazanin Madanihttps://www.mathworks.com/matlabcentral/profile/authors/12076353-nazanin-madanitag:www.mathworks.com,2005:Question/4768772019-08-20T14:54:37Z2019-08-20T16:21:58Znormxcorr2 - technical reference documentHello,
Inside the normxcorr2 function in Matlab, it's written in the comments that:
"Our technical reference document on NORMXCORR2 shows how to get from equation 2 of the Lewis paper to the code below."
where can this technical reference document be found?
Thanks,
OlgaOlga Libermanhttps://www.mathworks.com/matlabcentral/profile/authors/9297505-olga-libermantag:www.mathworks.com,2005:Question/505362012-10-11T16:48:13Z2019-08-20T16:21:01ZEigenvectors of Complex MatrixHello,
I'm working in Graph Spectra. The problem is that I want to find the eigenvalues and eigenvectors of a matrix with complex numbers. For instance, my matrix is:
[0 1+i 2i 3;1+i 0 3 1+4i;2i 3 0 1i;3 1+4i 1i 0]
I would like to know if the matlab function eig works for this kind of calculations. The idea is to find the partitioning with the second eigenvector.
If there is anybody working on this subject, I would like to have a little help.
Thank you!
Jose Sanchezhttps://www.mathworks.com/matlabcentral/profile/authors/1365226-jose-sancheztag:www.mathworks.com,2005:Question/4768882019-08-20T16:19:22Z2019-08-20T16:19:22ZPointer in a plotHi, I have a very big amount of observations, say 10k. Whit a previous edition of MATLAB if plotted value with a pointer i could point one and with the keyborad move left and right from this value. I can't do this thing with 2019b. Could anyone help?Alessandro Musso Iudicahttps://www.mathworks.com/matlabcentral/profile/authors/13313284-alessandro-musso-iudicatag:www.mathworks.com,2005:Question/4765242019-08-17T15:51:40Z2019-08-20T16:19:01ZRead Date time series format I want to read Date and time series from below format
% file.txt has time formatted data
[0803/135825.745523:GGBB:main.cc(182)]
[0803/135825.746634:NNFF:boat_control_xhramyos.cc(137)]
% My Code is as follows
VariableNames = {'Date'};
VariableWidths = [20]
VariableTypes = {'datetime'};
opts = fixedWidthImportOptions('VariableNames','SelectedVariableNames', [1]);
opts = setvaropts(opts, 'Date', 'InputFormat', 'MMdd/HHmmss.SSSSSS');
Content.update_engine = readtable('file.txt', opts);
I am getting following error as I am unable to read the time properly.
Warning: Unable to convert one or more variables to datetime. Specify the correct
InputFormat and DatetimeLocale properties in the DatetimeVariableImportOptions.
> In matlab.io.internal.functions.ReadTableWithImportOptionsText/executeImpl (line 82)
In matlab.io.internal.functions.ReadTableWithImportOptions/executeImpl (line 18)
In matlab.io.internal.functions.ReadTableWithImportOptionsText/execute (line 122)
In matlab.io.internal.functions.ReadTableWithImportOptions/execute (line 25)
In matlab.io.internal.functions.ExecutableFunction/validateAndExecute (line 98)
sriram shastryhttps://www.mathworks.com/matlabcentral/profile/authors/7949204-sriram-shastrytag:www.mathworks.com,2005:Question/4768542019-08-20T12:38:34Z2019-08-20T16:08:17Zhow to plot objective function with variablesxo=[0.0011,0.0049,0.3]; % assumptions
%[Q]=heatload1_new(xo)
%nvars=3;
A=[];
b=[];
Aeq=[];
beq=[];
lb=[0.001,0.002,0.01]; %lower bound
ub=[0.01,0.08,0.5]; %upper bound
nonlincon = @(x)constraint_new(x); % calling constraint function
Fitnessfun = @(x)weight_testvariable(x); %calling objective function
options = optimoptions(@fmincon,'Display','iter-detailed','Algorithm','sqp','MaxIterations',1500)
options = optimset('Display','iter','TolFun',1e-5)
[X,fval]=fmincon(Fitnessfun,xo,[],[],[],[],lb,ub,nonlincon,options)RAHUL KUMARhttps://www.mathworks.com/matlabcentral/profile/authors/15419640-rahul-kumartag:www.mathworks.com,2005:Question/4764832019-08-17T03:34:35Z2019-08-20T16:06:19ZHow to use textscan on a cell array without a loop?Hi everyone!
So, I have a structure with multiple fields. One of the fields I filled with strings from multiple, fairly large text files (~100,000 lines), and it is now a cell array. Here's the layout of the structure, and a sample of mystruct.out.
mystruct =
1Γ5 struct array with fields:
filename
out
size
mystruct.out =
{'%ACCDA,50,123.99,W,07512.001,E,2,11,2.2,1002.2,Z,,,,*22' }
{'%ACCDA,50,123.99,W,04412.001,E,2,11,2.2,1002.2,Z,,,,*20' }
{'%ACCDA,50,123.99,W,07112.001,E,2,11,2.2,1002.2,Z,,,,*2A' }
{'%ACCDA,50,123.99,W,08512.001,E,2,11,2.2,1002.2,Z,,,,*2E' }
{'%ACCDA,50,123.99,W,06512.001,E,2,11,2.2,1002.2,Z,,,,*2B' }
...
...
I want to avoid using a loop to perform the following, but I haven't been able to figure out how to do so on a mass scale without a loop.
I want to be able to use textscan, or some other method, to store the delimited strings into a new cell array, inside of an new mystruct field (like *** below)
Note: 'ii' is an index I'm using in a separate loop, but it's irrelevant to this issue.
for nlr = 1:mystruct(ii).size
fields = textscan(mystruct(ii).out{nlr},'%s','delimiter',',');
end
***(e.g. store into mystruct(ii).split(nlr))
How can I use textscan, or some other method, to "vectorize" the above loop?
Thanks!rtbme17https://www.mathworks.com/matlabcentral/profile/authors/10488096-rtbme17tag:www.mathworks.com,2005:Question/4768872019-08-20T16:06:13Z2019-08-20T16:06:13ZEditor limit line for app designer code viewIs there a Editor limit line property exist in app designer code view?
Or is there a way to add one?JIAYING WUhttps://www.mathworks.com/matlabcentral/profile/authors/8155277-jiaying-wutag:www.mathworks.com,2005:Question/3898892018-03-22T02:52:08Z2019-08-20T16:06:10ZHow to plot intensity profile of an imageI want to plot the intensity profile of this image. I tried using improfile but I don't really know how it works. Can anyone help?
<</matlabcentral/answers/uploaded_files/109552/Capture.PNG>>
Viron Gil Estradahttps://www.mathworks.com/matlabcentral/profile/authors/11916742-viron-gil-estradatag:www.mathworks.com,2005:Question/4767402019-08-19T18:11:24Z2019-08-20T16:05:56Zconvert string of numbers to doubleI have timestamp data saved as follows:
% Stim=["676, 933, 1645, 2069:.025:2069.5, 2327:.025:2327.5, 2542:.05:2543";"3"];
where each row would represent a column that corresponds to the experiment it was from. (3 is just a test value). Here I store the timestamps as a string so that I can concatonate different sized elements.
I was hoping to use str2double to extract these timestamps but I get NaN returned when I try.
% Stim=str2double(Stim(1)) - would be doing this itteratively
Thanks!!Joseph Sassoonhttps://www.mathworks.com/matlabcentral/profile/authors/13263740-joseph-sassoontag:www.mathworks.com,2005:Question/4768852019-08-20T15:50:57Z2019-08-20T16:03:37ZHow to remove a specific object from cell I have a cell containing objects.
AllObjects = {obj1 , obj2 obj3 ....., obj10}
i want to remove obj3 from AllObjects cell. Anil Rajajapantuluhttps://www.mathworks.com/matlabcentral/profile/authors/15405440-anil-rajajapantulutag:www.mathworks.com,2005:Question/4767442019-08-19T18:51:31Z2019-08-20T16:02:18ZLow-Level Graphics IssuesDear, I have Matlab 2019 a). I use Windows 10 in my notebook.
Until yesterday the program Matlab was works well.
But today the windows updated and now the Matlab doesn't works.
I updated the drivers manually, but the problem continue.
Could you help me, please ?
The message is:
Exception in thread "AWT-EventQueue-0": java.lang.RuntimeException: Waited 5000ms for: <6830bcde, 141a01c9>[count 2 [ add. 0, orig 2], qsz 0, owner <Startup Class Loader>, add.owner Startup Class Loader-SharedResourceRunner] - <AWT-EventQueue-0>
at jogamp.common.util.locks.RecursiveLockImpl01Unfairish.lock(RecursiveLockImpl01Unfairish.java:198)
at com.jogamp.opengl.GLProfile.initSingleton(GLProfile.java:199)
at com.jogamp.opengl.GLProfile.getDefaultDevice(GLProfile.java:2003)
at com.jogamp.opengl.GLCapabilities.<init>(GLCapabilities.java:84)
at com.mathworks.hg.peer.GLCanvasPeerFactory.getCaps(GLCanvasPeerFactory.java:22)
at com.mathworks.hg.peer.GLCanvasPeerFactory.createHGCanvasPeerWithComponent(GLCanvasPeerFactory.java:63)
at com.mathworks.hg.peer.GraphicsPeerWithComponent.createJOGLCanvas(GraphicsPeerWithComponent.java:19)
at com.mathworks.hg.peer.GraphicsPeer.doCreateCanvas(GraphicsPeer.java:112)
at com.mathworks.hg.peer.GraphicsPeer.access$100(GraphicsPeer.java:17)
at com.mathworks.hg.peer.GraphicsPeer$1.run(GraphicsPeer.java:167)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Exception in thread "AWT-EventQueue-0": java.lang.RuntimeException: Waited 5000ms for: <6830bcde, 141a01c9>[count 2 [ add. 0, orig 2], qsz 0, owner <Startup Class Loader>, add.owner Startup Class Loader-SharedResourceRunner] - <AWT-EventQueue-0>
at jogamp.common.util.locks.RecursiveLockImpl01Unfairish.lock(RecursiveLockImpl01Unfairish.java:198)
at com.jogamp.opengl.GLProfile.initSingleton(GLProfile.java:199)
at com.jogamp.opengl.GLProfile.getDefaultDevice(GLProfile.java:2003)
at com.jogamp.opengl.GLCapabilities.<init>(GLCapabilities.java:84)
at com.mathworks.hg.peer.GLCanvasPeerFactory.getCaps(GLCanvasPeerFactory.java:22)
at com.mathworks.hg.peer.GLCanvasPeerFactory.createHGCanvasPeerWithComponent(GLCanvasPeerFactory.java:63)
at com.mathworks.hg.peer.GraphicsPeerWithComponent.createJOGLCanvas(GraphicsPeerWithComponent.java:19)
at com.mathworks.hg.peer.GraphicsPeer.doCreateCanvas(GraphicsPeer.java:112)
at com.mathworks.hg.peer.GraphicsPeer.access$100(GraphicsPeer.java:17)
at com.mathworks.hg.peer.GraphicsPeer$1.run(GraphicsPeer.java:167)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Exception in thread "AWT-EventQueue-0": java.lang.RuntimeException: Waited 5000ms for: <6830bcde, 141a01c9>[count 2 [ add. 0, orig 2], qsz 0, owner <Startup Class Loader>, add.owner Startup Class Loader-SharedResourceRunner] - <AWT-EventQueue-0>
at jogamp.common.util.locks.RecursiveLockImpl01Unfairish.lock(RecursiveLockImpl01Unfairish.java:198)
at com.jogamp.opengl.GLProfile.initSingleton(GLProfile.java:199)
at com.jogamp.opengl.GLProfile.getDefaultDevice(GLProfile.java:2003)
at com.jogamp.opengl.GLCapabilities.<init>(GLCapabilities.java:84)
at com.mathworks.hg.peer.GLCanvasPeerFactory.getCaps(GLCanvasPeerFactory.java:22)
at com.mathworks.hg.peer.GLCanvasPeerFactory.createHGCanvasPeerWithComponent(GLCanvasPeerFactory.java:63)
at com.mathworks.hg.peer.GraphicsPeerWithComponent.createJOGLCanvas(GraphicsPeerWithComponent.java:19)
at com.mathworks.hg.peer.GraphicsPeer.doCreateCanvas(GraphicsPeer.java:112)
at com.mathworks.hg.peer.GraphicsPeer.access$100(GraphicsPeer.java:17)
at com.mathworks.hg.peer.GraphicsPeer$1.run(GraphicsPeer.java:167)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Leonardo Barbosa Torres dos Santoshttps://www.mathworks.com/matlabcentral/profile/authors/14239507-leonardo-barbosa-torres-dos-santostag:www.mathworks.com,2005:Question/4768792019-08-20T15:00:18Z2019-08-20T16:02:17ZEasiest way to change variables based on decisions made by user?I am using kNN classification on data extracted via tracking of video.
I have different predictors that need to be loaded based on what set of videos the user wants to process (low height or high height)
What is the easiest way to present a choice in the gui when the program is first ran, one that poses the question:
What videos are you processing?
(tickbox for high height)
(tickbox for low height)
Then based on which the user selects, loads either predictor file a or predictor file b?
CheersJames Morrishttps://www.mathworks.com/matlabcentral/profile/authors/14890179-james-morris