https://in.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2020-06-05T22:53:57Ztag:in.mathworks.com,2005:Question/4758262019-08-12T13:46:06Z2020-06-05T22:53:57Zclear all output codeIs it possible in matlab live script to "clear all output" with a program code?
ga rechttps://in.mathworks.com/matlabcentral/profile/authors/10477303-ga-rectag:in.mathworks.com,2005:Question/5429812020-06-05T17:15:32Z2020-06-05T22:53:07ZColumnar vector n elements Hi,
How to create a column element n element in Matlab? please helpMarcel Królhttps://in.mathworks.com/matlabcentral/profile/authors/18702416-marcel-kroltag:in.mathworks.com,2005:Question/5428552020-06-05T14:06:33Z2020-06-05T22:46:10ZMethod for Tracking People with Multiple CamerasHi freinds .....
I have a project for ( home surveillance) . part encryption is completed , I want your suggestion( best method ) for with Multiple Cameras and compare with authentication of people ( 10 person ) , after it will identifiers on Intruder .omar A.alghafoorhttps://in.mathworks.com/matlabcentral/profile/authors/18058720-omar-a-alghafoortag:in.mathworks.com,2005:Question/5425732020-06-05T03:05:25Z2020-06-05T22:45:47ZPlotting 3D cube as 2D layersHello,
I have a mathlab code for 3D data which were generated using "For" loops with multiple iterations. To be specific, the following "(function)" s are from equations of finite difference analysis.
ic = 0
for i = 1:100
for x = 1:N
for y = 1:N
for z = 1:N
V1(x,y,z) = (function)
V2(x,y,z) = (function)
V3(x,y,z) = (function)
end
end
ic = ic + 1
if ic>10
ic =0
end
end
"(function)" example: V2(x+1,N-1,k-1)+V1(x-1,N-2,k+1)...so on
I want to plot V1(x,z) 2D layer with a fixed value of "y". Example V1(:,1,:). I could not find a way to do it.
Also I would like to know what are the other ways i can generate different plots to analyze the V1,V2 and V3
Thank you !!!!!!!The Sanchihttps://in.mathworks.com/matlabcentral/profile/authors/8174783-the-sanchitag:in.mathworks.com,2005:Question/5414122020-06-03T15:03:38Z2020-06-05T22:45:00ZHow do I selectively delete time points from datasetsI would like to add in a piece of code that gives me the option to selectivly delete rows (bad data points) from my datasets. I run two files alongside each other (data and time) and I need to change them both accordingly. This is the code I have so far
However, when I run this code I get the following error
Any suggestions of how to fix this would be much appriciated
Thank youEmma Tonghttps://in.mathworks.com/matlabcentral/profile/authors/11900141-emma-tongtag:in.mathworks.com,2005:Question/4533282019-03-29T19:05:56Z2020-06-05T22:42:02ZASSIGNMENT: TEXT FILES Write a function called char_counter that counts the number of a certain character in a text file. The function takes two input arguments, fname, a char vector of the filename and character, the char it counts in the file. When testing with '' your solution returned -1 which is incorrect. (0)
This error pops up while doing the assignment.
can anyone tell me why is this error popping and the meaning of the statement mentioned above.
when the character is ' " ' then i get a finite answer. and when the character is ' ' ' then too answer is a finite number. but i dont understand what the above bold text means....
my code
function charnum = char_counter(fname,character)
fid=fopen(fname);
if fid< 0
charnum = -1;
return;
end
if strcmp(character,'')==1
charnum=0;
return;
end
if double(character)>=35 && double(character)<=43 && double(character) ~=39 && double(character) ~= 41 && double(character) ~= 40
charnum = 0;
return;
end
if double(character) >=60 && double(character) <=64 && double(character) ~= 63
charnum = 0;
return;
end
if double(character) == 81 || double(character) == 88 || double(character) == 90
charnum = 0;
return;
end
cc = fgets(fid);
sumv=0;
while ischar(cc)
z = sprintf('%s',cc);
k = strfind(z,character);
sumv = sumv + length(k);
cc = fgets(fid);
end
charnum = sumv;
if charnum == 0
charnum =-1;
return;
endRakshith Rhttps://in.mathworks.com/matlabcentral/profile/authors/15060157-rakshith-rtag:in.mathworks.com,2005:Question/5431732020-06-05T22:35:11Z2020-06-05T22:35:11ZHey can you please help me with these errors im getting from my GUI% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
syms x;
format long
h=get(handles.edit1,'string');
a=str2double(get(handles.edit2,'string'));
b=str2double(get(handles.edit3,'string'));
it=str2double(get(handles.edit4,'string'));
ha=subs(h,a);
hb=subs(h,b);
i=0;
while i~=it
i=i+1;
r=(ha*b-hb*a)/(ha-hb);
fr=subs(h,r);
if fr>it; a=b; b=r;
end
end
if i==it;
set(handles.raiz,'String',r);
end
THESE ARE MY ERRORS
Error using matlab.ui.control.UIControl/set
While setting the 'String' property of UIControl:
String should be char, numeric or cell array datatype.
Error in metodo_de_la_secante>pushbutton1_Callback (line 187)
set(handles.raiz,'String',r);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in metodo_de_la_secante (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)metodo_de_la_secante('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl CallbackAlejandro Valdivia Hernandezhttps://in.mathworks.com/matlabcentral/profile/authors/15202188-alejandro-valdivia-hernandeztag:in.mathworks.com,2005:Question/5431702020-06-05T22:26:14Z2020-06-05T22:34:05ZHow can I implement systematic erasure reed solomon code so the input message is not changedHow can I implement systematic erasure reed solomon code so the input message is not changed and the generated extra parity data is appended to the original data.mahmoud alnaanahhttps://in.mathworks.com/matlabcentral/profile/authors/9841345-mahmoud-alnaanahtag:in.mathworks.com,2005:Question/5430652020-06-05T19:28:00Z2020-06-05T22:15:39ZFind set of all adjacent points that are close to each otherI would like to find in Y[n] a set of adjacent points that are close to each other, but I don't get all the desired points. For example.
Y = [ 1.1 1.12 9.2 8.3 8.295 8.292 4.1 4.12 4.19];
dY_idx = find(abs(diff(Y)) < 0.022);
Y_adj_close = Y(dY_idx)
This code results in:
Y_adj_close =
1.1000 8.3000 8.2950 4.1000
But I would like the result to be:
Y_adj_close =
1.1000 1.1200 8.3000 8.2950 8.2920 4.1000 4.12
How can I get the desired result? (Note: I probably could also do a Y = fliplr(Y) followed by a second round and then combine results to get all the unique points, but that would be two sets of operations on a large vector. Hoping for a faster solution.)Paul Hoffrichterhttps://in.mathworks.com/matlabcentral/profile/authors/17585002-paul-hoffrichtertag:in.mathworks.com,2005:Question/5431672020-06-05T22:14:04Z2020-06-05T22:14:50ZHow to update value of a variable when a button is pushed? What am I doing wrong in this code?I have introduced a variable "value" in the opening function. I want to add a specific number in the same variable when a button is pressed and then want it to update on when next button is pressed. Then I want to display the final value of the variable "value" when pushbutton10 is pressed.
When I run this code, it gives zero as output no matter what button is pressed. Please check this code and tell me what am I doing wrong here? It would be a great help!
function varargout = aaabbb(varargin)
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @aaabbb_OpeningFcn, ...
'gui_OutputFcn', @aaabbb_OutputFcn, ...
'gui_LayoutFcn', [], ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before aaabbb is made visible.
function aaabbb_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for aaabbb
handles.output = hObject;
handles.value=0;
% Update handles structure
guidata(hObject, handles);
% --- Outputs from this function are returned to the command line.
function varargout = aaabbb_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
handles.value = handles.value + 148;
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
handles.value = handles.value + 161;
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
handles.value = handles.value + 7;
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
handles.value = handles.value + 0;
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
handles.value = handles.value + 45;
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
handles.value = handles.value + 80;
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
handles.value = handles.value + 82;
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
handles.value = handles.value + 3;
% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
handles.value = handles.value + 0;
% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
disp(handles.value)
Safeena Ahsanhttps://in.mathworks.com/matlabcentral/profile/authors/9355572-safeena-ahsantag:in.mathworks.com,2005:Question/5431522020-06-05T21:40:07Z2020-06-05T22:13:16ZAccess .mlapp data in .m file after app closesHello,
I have a script (.m) that calls a app (.mlapp) that I created using AppDesigner. The app is designed to collect user input. After the user enters the values, he/she clicks an OK button which propmpts the app to close. After the app closes, I want to access the user data from the app in the scipt (.m) and perform operations with the data. How do I do this?
I tried creating "public" properties and storing the values in the said created public properties, but I cant access those properties after the app is closed because the handle is deleted when the app deletes. I understand that it is possible to transfer data before the app deletes but the problem with that is that I don't know when the user is finished entering the data until the app is deleted.
My code in the script (.m) looks something like this:
H = myApp;
waitfor(H)
%Here I need to access the data from myAppJonathan Avesarhttps://in.mathworks.com/matlabcentral/profile/authors/15577646-jonathan-avesartag:in.mathworks.com,2005:Question/5431642020-06-05T22:10:18Z2020-06-05T22:10:18ZWatershed Segmentation is resulting in more segments than necessary. How can I change this?I have a ground truth image and I want to find its skeleton points and from these skeleton points I want to use watershed to recreate the ground truth image.
The problem is, when I use bwmorph(skel), the skeleton points touch each other and it results in an under segmented image. I tried to erode the image before I find the skeleton points, and this resulted in oversegmentation. The code and images are below:
img = imread('181091.jpg');
img = double(img);
seg = readSeg('181091.seg');
R = img(:,:,1);
G = img(:,:,2);
B = img(:,:,3);
[GxR,GyR] = gradient(R);
[GxG,GyG] = gradient(G);
[GxB,GyB] = gradient(B);
Grad = sqrt(GxR.^2 + GyR.^2 + GxG.^2 + GyG.^2 + GxB.^2 +GyB.^2);
img_skel = 0;
for i = 1:max(max(seg))
seg_sel = seg==(i);
seg_sel = imerode(seg_sel,ones(3,3));
img_skel1 = bwmorph(seg_sel,'skel',inf);
img_skel = img_skel + img_skel1;
end
figure, imagesc(img_skel)
watersh = imimposemin(Grad,img_skel);
Labels = watershed(watersh);
Labels = label2rgb(Labels);
The ground truth has 6 segments:
However, my result (with imerode, bwmorph, imimposemin and watershed) has 14 segments:
I want to be able to have the same number of segments. What could I add or change in my code? If I don't use imerode, the image looks like this:
Rubahttps://in.mathworks.com/matlabcentral/profile/authors/13076082-rubatag:in.mathworks.com,2005:Question/3174022016-12-19T04:13:56Z2020-06-05T21:59:06Zhow to create a notch filter for the image to remove noise?i have an image with periodic noise
<</matlabcentral/answers/uploaded_files/65799/c.jpg>>
after applying the fourier transform and fftshift i got
<</matlabcentral/answers/uploaded_files/65800/s.jpg>>
help me to design the notch filters to remove the noise
Siddardha Mamillapallihttps://in.mathworks.com/matlabcentral/profile/authors/9296704-siddardha-mamillapallitag:in.mathworks.com,2005:Question/5431582020-06-05T21:55:19Z2020-06-05T21:55:19ZUniformly spaced 3D point cloudHow to remesh 3D point cloud in a way that its points are evenly spaced? I have a surface (figure and data attached) and I would want all rectangles to be of the same certain size (so that the points are located on the same distance from each other). ScatteredInterpolant did not work:(zilorinahttps://in.mathworks.com/matlabcentral/profile/authors/16327769-zilorinatag:in.mathworks.com,2005:Question/5419042020-06-04T06:39:07Z2020-06-05T21:53:48Zchanging YLabel position and outerpositionIf YLabel position change that outerposition mode of axes don't work for YLabel.
It's correct?
figure;
ax1 = axes('OuterPosition',[0 0.50 1.0 0.50]);
ax1.ActivePositionProperty = 'outerposition';
plot(ax1,0:10,0:10);
ax1.Title.String = 'Preserve OuterPosition';
ax1.YLabel.Rotation = 0;
ax1.YLabel.String = 'Preserve OuterPosition';
ax1.YLabel.HorizontalAlignment = 'right';
ax1.YLabel.VerticalAlignment = 'top';
ax1.YLabel.Position(2) = ax1.YLabel.Position(2)+2; % outerposition mode of axes don't work for YLabel after the line
ax1.YLabel.HorizontalAlignment = 'right';
ax1.YLabel.VerticalAlignment = 'top';
outerpos = ax1.OuterPosition;
ti = ax1.TightInset;
left = outerpos(1) + ti(1);
bottom = outerpos(2) + ti(2);
ax_width = outerpos(3) - ti(1) - ti(3);
ax_height = outerpos(4) - ti(2) - ti(4);
ax1.Position = [left bottom ax_width ax_height];
Eugene Paymurzovhttps://in.mathworks.com/matlabcentral/profile/authors/969307-eugene-paymurzovtag:in.mathworks.com,2005:Question/5431552020-06-05T21:50:26Z2020-06-05T21:50:26ZRandom numbers around y-valuesHello, I've got a set of y-values. I'd like Matlab to plot random numbers around these y-values (max difference:15%). For you info: y values are given in a .txt file (let's say 100x1). Thx in advance Niklas Kurzhttps://in.mathworks.com/matlabcentral/profile/authors/18516014-niklas-kurztag:in.mathworks.com,2005:Question/5431162020-06-05T20:24:14Z2020-06-05T21:46:15ZHow to make gauge value variable?I created two gauges using App Designer. Went into corresponding gauge codes and change the value to constant value such as 19 and 54 just as given in the pic below. However, what I want is a moveable arc. For example 'gauge' goes from 0 to 45 smoothly and changing between 45 to 35 as long as I keep open the app. How to achieve this? Gauge code doesn't allow me to edit on code so I couldn't play with it. :/ Any ideas?
Murat Sarihttps://in.mathworks.com/matlabcentral/profile/authors/18612321-murat-saritag:in.mathworks.com,2005:Question/5431432020-06-05T21:06:19Z2020-06-05T21:35:42ZCan someone better explain what the fullfile function does on Matlab (the mathworks explanation didn't help me)?I read the explanation on mathworks (below), but still do not understand what the fullfile function does. Can someone explain is more clearly to someone who is new to matlab? For example, I'm not really sure what a 'full file specification' is or what 'platform-dependent' means. Thank you!
f = fullfile(filepart1,...,filepartN) builds a full file specification from the specified folder and file names. fullfile inserts platform-dependent file separators where necessary, but does not add a trailing file separator. On Windows® platforms, the file separator character is a backslash (\). On other platforms, the file separator might be a different character.
fullfile replaces all forward slashes (/) with backslashes (\) on Windows. On UNIX® platforms, the backlash (\) character is a valid character in file names and is not replaced.
fullfile does not trim leading or trailing separators. fullfile collapses inner repeated file separators unless they appear at the beginning of the full file specification. fullfile also collapses relative directories indicated by the dot symbol, unless they appear at the end of the full file specification. Relative directories indicated by the double-dot symbol are not collapsed.Victoria Helmhttps://in.mathworks.com/matlabcentral/profile/authors/18620001-victoria-helmtag:in.mathworks.com,2005:Question/5430712020-06-05T19:29:26Z2020-06-05T21:34:48Zif statement matlab problem I got issue on my code. That I put if statement under the else statement it's return a weird number.
The background here is in1 is for vector of original and resubimission grade. in2 is a character vector with entries reading either 'a' or 'm' , to determine if the two grade would be treat with average or maxium. But one requiurement is that when the resubimission grade is lower than the original grade, it would be picked original grade instead of average grade. Only when resubmission is higher and choose average. I added this argument under the else statement that
if(in1(ct>ct+1))
score=score+ct;
but the result comes out run. How should I fix it.
Mariahttps://in.mathworks.com/matlabcentral/profile/authors/18485433-mariatag:in.mathworks.com,2005:Question/5430892020-06-05T19:52:03Z2020-06-05T21:33:06ZHow to find the peak value of a graph and how to plot them?Hi,
I need to find the peak value of each force for the plotted graph and locate it in the graph.
I already use findpeaks but there is no answer and no error informed.
I'm not sure the flow and how to apply the findpeaks command.
Thank you in advance!
X=xlsread('Filtered JCF PHASE 1.xlsx',4,'Z5:AC55');
Y=xlsread('JCF PHASE 1_5UP.xlsx',4,'AN5:AP55');
Z=xlsread('JCF PHASE 1_5DW.xlsx',4,'AN5:AP55');
x1 = X(:,1); %the percentage
y1= X(:,2); %the force value 1
y2= Y(:,1); %the force value 2
y3= Z(:,1); %the force value 3
[pks,locs] = findpeaks (y1,x1);
findpeaks (y1, x1);
subplot(3,1,1);
plot(x1,y1,'r',x1,y2,'g',x1,y3,'b','Linewidth',3);
title('JCF HIP X');
xlhand = get(gca,'xlabel');
set(xlhand,'string','Percentage of stance phase (%)','fontsize',10)
ylhand = get(gca,'ylabel');
set(ylhand,'string',{'JCF (N)'},'fontsize',10);arifahazwani AYhttps://in.mathworks.com/matlabcentral/profile/authors/17775540-arifahazwani-aytag:in.mathworks.com,2005:Question/5430262020-06-05T18:29:23Z2020-06-05T21:32:05ZImproving speed of large interpolation (33 million to 33 billion elements)I am importing a bin file with ~33million elements and need to interpolate 1000 elements between the existing elements. As you can imagine, this isn't spedy and quickly consumes all the RAM on my machine. The code looks something like this.
data = fopen('ThirtyMillionElementFile.bin','r');
fclose('ThirtyMillionElementFile.bin');
data = interp(data,1000); %If I assign the interpolated value to a new variable such as...
% interpolatedData = interp(data,1000); the rest of the code breaks (seems related to memory issues).
filteredData = filter(importedFilterValues1, importedFilterValues2, data);
Overall this works but takes about 30 seconds. If I feed a larger file such as 66million elements and interp by 1000 the computer will completely lock up due to all 32 Gb of RAM and 100% of disk being used. Since I need to run larger files, how can I go about speeding this up and potentially improving the performance? In addition, I am not able to modify the filter in anyway. The whole idea is to use a legacy filter design.
I have found that tall arrays are not compatible with interp. And due to the 6 operations being done after interp and before the gather, tall arays will slow the code down to about an hour run time instead of 3 minutes total.
gpuArray doesn't help because I'm limited by 6Gb of Ram which will cause the code to error out.
I absolutely can and will add more RAM, but I am curious to know if there are other solutions that can be used in conjunction with increased hardware specs.
(Side Question: How is matlab able to store these massive arrays? There is no way I have enough RAM)David Almodovarhttps://in.mathworks.com/matlabcentral/profile/authors/8081978-david-almodovartag:in.mathworks.com,2005:Question/5431492020-06-05T21:28:01Z2020-06-05T21:28:01ZHow can I find the Power spectral density of a filtered Noise?I have this following code of generating noise and filtering it.. However I ailrd to plot its PSD of filtered Noise, as mentioned in coments?
N=2^10;
time=1:1:N;
time=time*1e-3;
time=time/N;
size(time)
bandwidth=100e3;
irn=10e-9;
plotting=1;
noisebw=(1/(max(time)/length(time)) )/2;
%%% SENSOR DATA
ws=(noisebw)/bandwidth;
Wn=1/ws;
[b,a] = butter(2,Wn,'low');
VN1=irn*sqrt(bandwidth);
VN2=sqrt(ws);
noise1=VN1*randn(size(time));
noise2=filter(b,a,noise1);
noise3=VN2*noise2; % filtered Noise
if plotting
figure(100);
plot(time,noise1,'-k','Linewidth',2);
hold on;
plot(time,noise2,'-y','Linewidth',2);
plot(time,noise3,'-m','Linewidth',2);
grid on;
legend('noise high bw','filtered','noise low bw');
title('noise source function outputs');
end
Syed Adeelhttps://in.mathworks.com/matlabcentral/profile/authors/17761816-syed-adeeltag:in.mathworks.com,2005:Question/5431462020-06-05T21:27:39Z2020-06-05T21:27:39Zexplict (pointwise) function from numerical solution to implicit equationI can plot the numerical solutions to a complicated expression f(x,y)=0 over intervals for x and y using fimplicit(f,interval). However, how do I then define/specify an explicit relation y=g(x) pointwise using the numerical values computed from f(x,y)=0 for use in a separate expression? (There is a functional relation.)Laurence Kranichhttps://in.mathworks.com/matlabcentral/profile/authors/18548916-laurence-kranichtag:in.mathworks.com,2005:Question/5431222020-06-05T20:36:17Z2020-06-05T21:24:59ZHow much money will I accumulate over x amount of yearsCreate a loop to find how much money I will have after n amount of years. You have an initial deposit of $1000 and add $65 each month to an account that gains 1.5% each month. How much money will you have after 13 years?Dillan Guzmanhttps://in.mathworks.com/matlabcentral/profile/authors/17610528-dillan-guzmantag:in.mathworks.com,2005:Question/5429842020-06-05T17:18:34Z2020-06-05T21:15:58Zode45 and euler not working for random signalWhen trying to simulate a first order system subject to a random input that changes value at fixed intervals, neither my ode45 nor euler integration attempts make sense to me. Neither of them follow the inut signal. Please help!
(This code reqs 2016b or later I think)
clc;clear;close all;format compact
w_filt = 10*2*pi; % first order filter
t = linspace(0,1,1000);
dt = t(2)-t(1);
inits = [0];
%% Try ODE 45
Eqns = @(t,s) eqns(t,s,dt,w_filt);
[t,x] = ode45(Eqns,t,inits);
for i = 1:length(t)
[dx(i,:),ext(i)] = Eqns(t(i),x(i));
end
in = ext;
du = dx;
u = x;
%% Try Euler
X = inits;
for i = 1:length(t)-1
dX(i) = w_filt*(in(i) - X(i));
X(i+1) = du(i)*dt + X(i);
end
dX(end+1) = 0;
%% Plots
figure(1);
title('ODE45');
plot(t,u,t,du,t,in)
legend('u','du','input')
figure(2);
title('Euler Integration')
plot(t,X,t,dX,t,in)
legend('u','du','input')
%% EOM
function [dx,ext] = eqns(t,x,dt,w_relax)
global randval
u = x;
in = randval;
if rem(t,100*dt) == 0 || t == 0
in = 0.1*pi/180*(2*rand-1);
randval = in;
end
du = w_relax*(in - u);
dx = du;
ext = in;
endSEEmULATERhttps://in.mathworks.com/matlabcentral/profile/authors/10447945-seemulatertag:in.mathworks.com,2005:Question/4451882019-02-15T16:58:22Z2020-06-05T21:11:34ZPlotting Antarctica filled polygon with gshhs function fills the inverse of AntarcticaI am using the gshhs function to load the latest version of GSHHG coastal data (version 2.3.7). This data was downloaded from https://www.ngdc.noaa.gov/mgg/shorelines/data/gshhg/latest/. Information about this dataset: https://www.ngdc.noaa.gov/mgg/shorelines/
I plot the filled polygons using geoshow and for the parts of the Earth north of S (e.g. Anarctica) it works great. However, for Antarctica, it fills the inverse of Anartica instead.
Here is example code use to plot Antarctica:
% Antarctica test
figure('Name', 'Antartica', 'NumberTitle', 'off', 'Color', 'white');
worldmap('Antarctica');
projection = gcm;
latlim = projection.maplatlimit;
lonlim = projection.maplonlimit;
if ~exist('gshhs_f.i', 'file');
gshhs('gshhs_f.b', 'createindex');
end
% Load the GSHHG coastal polygon data version 2.3.7 - Full Resolution
antarctica = gshhs('gshhs_f.b', latlim, lonlim);
levels = [antarctica.Level];
land = (levels == 1);
lake = (levels == 2);
island = (levels == 3); % island in a lake
pond = (levels == 4); % pond in an island in a lake
ice_front = (levels == 5); % ice shelves around Antarctica
grounding_line = (levels == 6); % land of Antarctica
geoshow([antarctica(ice_front).Lat], [antarctica(ice_front).Lon], 'DisplayType', 'Polygon', 'FaceColor', [230/255 230/255 230/255]); % gray
geoshow([antarctica(grounding_line).Lat], [antarctica(grounding_line).Lon], 'DisplayType', 'Line', 'Color', [255/255 105/255 180/255]); % hot pink
geoshow([antarctica(land).Lat], [antarctica(land).Lon], 'DisplayType', 'Polygon', 'FaceColor', [ 0/255 100/255 0/255]); % forest green
geoshow([antarctica(lake).Lat], [antarctica(lake).Lon], 'DisplayType', 'Polygon', 'FaceColor', [ 0/255 0/255 128/255]); % navy blue
geoshow([antarctica(island).Lat], [antarctica(island).Lon], 'DisplayType', 'Polygon', 'FaceColor', [210/255 105/255 30/255]); % chocolate
geoshow([antarctica(pond).Lat], [antarctica(pond).Lon], 'DisplayType', 'Polygon', 'FaceColor', [ 84/255 84/255 84/255]); % light steel blue
setm(gca, 'FFaceColor', 'cyan'); % set background color (should be seas, oceans, bays, etc.)
box('off');
xlabel('lon (deg)', 'fontsize', 12, 'color', 'b');
ylabel('lat (deg)', 'fontsize', 12, 'color', 'b');
axis('tight');
axis('fill');
grid('on');
The results of said plot:
The light gray is supposed to be Antarctica and the cyan is supposed to be the seas, oceans, bays, etc. Clearly it is the inverse.
Here is a simple example of another part of the world (New York City, NY, USA) that plots just fine:
% NYC test
figure('Name', 'NYC, USA', 'NumberTitle', 'off', 'Color', 'white');
latlim = [40 41];
lonlim = [-75 -73];
worldmap(latlim, lonlim);
% Load the GSHHG coastal polygon data version 2.3.7 - Full Resolution
if ~exist('gshhs_f.i', 'file');
gshhs('gshhs_f.b', 'createindex');
end
nyc = gshhs('gshhs_f.b', latlim, lonlim);
levels = [nyc.Level];
land = (levels == 1);
lake = (levels == 2);
island = (levels == 3); % island in a lake
pond = (levels == 4); % pond in an island in a lake
ice_front = (levels == 5); % ice shelves around Antarctica
grounding_line = (levels == 6); % land of Antarctica
geoshow([nyc(ice_front).Lat], [nyc(ice_front).Lon], 'DisplayType', 'Polygon', 'FaceColor', [230/255 230/255 230/255]); % gray
geoshow([nyc(grounding_line).Lat], [nyc(grounding_line).Lon], 'DisplayType', 'Line', 'Color', [255/255 105/255 180/255]); % hot pink
geoshow([nyc(land).Lat], [nyc(land).Lon], 'DisplayType', 'Polygon', 'FaceColor', [ 0/255 100/255 0/255]); % forest green
geoshow([nyc(lake).Lat], [nyc(lake).Lon], 'DisplayType', 'Polygon', 'FaceColor', [ 0/255 0/255 128/255]); % navy blue
geoshow([nyc(island).Lat], [nyc(island).Lon], 'DisplayType', 'Polygon', 'FaceColor', [210/255 105/255 30/255]); % chocolate
geoshow([nyc(pond).Lat], [nyc(pond).Lon], 'DisplayType', 'Polygon', 'FaceColor', [ 84/255 84/255 84/255]); % light steel blue
setm(gca, 'FFaceColor', 'cyan'); % set background color (should be seas, oceans, bays, etc.)
box('off');
xlabel('lon (deg)', 'fontsize', 12, 'color', 'b');
ylabel('lat (deg)', 'fontsize', 12, 'color', 'b');
axis('tight');
axis('fill');
grid('on');
Here is its output:
This was the output expected.
I understand this is probably an issue related to the singularites near the poles and MATLAB not quite understanding how to draw a polygon that is open in rectilinear space but closed in spherical space. I have attempted some simple attempts at closing the polygon in rectilinear space myself to no avail. Any assistance with plotting this data in MATLAB R2017b using the full resolution of the GSSHG coastal data set would be much appreciated.Jamie LaPointehttps://in.mathworks.com/matlabcentral/profile/authors/1185224-jamie-lapointetag:in.mathworks.com,2005:Question/5431342020-06-05T20:46:20Z2020-06-05T21:10:16ZFibonacci.m for Fibonacci SeriesHere is a .m file what I made for Fibonacci Series:
function F = Fibonacci(n)
%Fibonacci Series: Calculate the nth term
%The Fibonacci numbers are the sequence 0, 1, 1, 2, 3, 5, 8, 13, 21….
%Given that the first two numbers are 0 and 1, the nth Fibonacci number is
%Fn = Fn–1 + Fn–2.
%Applying this formula repeatedly generates the Fibonacci numbers.
F(1) = 0;
F(2) = 1;
i = 3;
while i <= n
F(i) = F(i-1)+F(i-2);
i = i+1;
end
F = F(n);
end
If I input n is single number such as:
n=10;
Fibonacci(n)
It can give me the correct answer:
ans = 34
However, if I input n is an array, such as:
n=1:10;
Fibonacci(n)
It gives the error warning:
Index exceeds the number of array elements (2).
Error in Fibonacci (line 15)
F = F(n);
I just wonder why it occurs this information?Siyi Wanghttps://in.mathworks.com/matlabcentral/profile/authors/18549687-siyi-wangtag:in.mathworks.com,2005:Question/4414302019-01-25T09:33:45Z2020-06-05T21:09:23Zhow to return values from .mlapp to the .m callerI made a matlab application (.m) for which I want to setup some parameters using a parameter window built with appdesigner (.mlapp). I was perfectly able to send values from .m to .mlapp, but I am not able to make the oposite i.e. return values from the .mlapp to .m.
My parameter window just contains 2 sliders.
There is probably something I dont understand. Can someone help me on this. Thankspascal plissonhttps://in.mathworks.com/matlabcentral/profile/authors/4010400-pascal-plissontag:in.mathworks.com,2005:Question/5424922020-06-04T23:22:49Z2020-06-05T21:07:37ZHow do I save my MATLAB work and notes onto a PDF file or Google Doc?I am currently learning MATLAB using online tutorials through YouTube and Coursera. As I watch these tutorials, I follow along in MATLAB Online for practice. Is there a way for me to save my work in MATLAB in Google Doc, PDF, or even a word doc so that I can type my notes into the same file and share it with others?Victoria Helmhttps://in.mathworks.com/matlabcentral/profile/authors/18620001-victoria-helmtag:in.mathworks.com,2005:Question/5431402020-06-05T21:05:35Z2020-06-05T21:05:35ZChanging objects RCS as a function of azimuth and elevation angleI'm trying to use the SAR simulation (which you can conveniently run by just typing openExample('phased/SyntheticApertureRadarImageFormationExample') in the command window) to model a Synthetic Aperture Radar that visualizes objects whose reflectivity (RCS) changes. When I changed the phased.RadarTarget() object I saw that when I instantiated it to simulate signal reflection there were problems with the parameters. It expected 3 parameters. Once I learned what they were I was getting an error that the first parameter had to be a struct. I changed my complex matrix (which represents an incident signal) to a struct, but then an error popped up saying that I had to change it to a double. The code below simulates the same error I'm getting without having to run the simulation.
% General_Playground.m
clear;
clc;
% Random matrices (Scattering)
a = randi([0,1],[181,91]);
b = randi([0,1],[181,91]);
f = randi([0,1],[181,91]);
d = randi([0,1],[181,91]);
% Reference angles
az = input('Input the azimuth angle');
el = input('Input the elevation angle');
% Generate complex numbers
for ix = 1:2002
for iy = 1:3
q = randi([0,15]);
w = randi([0,15]);
r(ix,iy) = q + w*1i;
end
end
% Create target
target = phased.RadarTarget('EnablePolarization',true,'ScatteringMatrix',[a(az,el),b(az,el);b(az,el),f(az,el)] ...
,'OperatingFrequency',600e6);
% Target reflection
y = target(r,[45,0],azelaxes(180,0));
disp(y(1:10));Gabriel Quinterohttps://in.mathworks.com/matlabcentral/profile/authors/15908758-gabriel-quinterotag:in.mathworks.com,2005:Question/5431192020-06-05T20:27:10Z2020-06-05T20:57:21ZFinding all index for a given row and incrementing of every 10 indices - implement something like this and put it into a foreloop.Hello all,
If I had a martix of 5 by 10, and in each of the index(s) there are numbers that increment.
example:
row(1), col(all) = 1, 3, 6, 19, 20, 21, 50, ... so on
row(2), col(all) = 2, 5, 6, 15, 16, 30, 54, ... so on
:
:
so on
Then the indexes (1) and (5) which the values are 1 and 20. How do I implement something like this and put it into a foreloop.
Now I looked into find command for Matlab, but can't make sense of how to properly implement it into my code for finding two of the indexes like I explained above. SugerCodeCudehttps://in.mathworks.com/matlabcentral/profile/authors/13327750-sugercodecudetag:in.mathworks.com,2005:Question/5394552020-06-01T06:19:06Z2020-06-05T20:51:59ZImage translation using fourier transformI have shifted an image by certain pixels in the Fourier (frequency) domain and brought it back to the time domain. My question is if the noise associated with my image before translation is same as the noise associated with it after translation.Asrith Pylahttps://in.mathworks.com/matlabcentral/profile/authors/9464323-asrith-pylatag:in.mathworks.com,2005:Question/5431252020-06-05T20:36:31Z2020-06-05T20:47:11Zwhats is that error in matlab?When I write this code, the matrix that is called (confusion matrix) does not appear to me .... But this shape appears and says these words and I do not understand the problem:
% load('P2.mat')
% load('P.mat')
% load('T.mat')
net=feedforwardnet(2);
net=train(net,P,T);
view(net)
P3=net(P2);
plotconfusion(T,P3)
Aya Ahmedhttps://in.mathworks.com/matlabcentral/profile/authors/17477653-aya-ahmedtag:in.mathworks.com,2005:Question/5431312020-06-05T20:46:17Z2020-06-05T20:46:17Zlinear or reciprocating controlhow can i control reciprocating motion pistom in simulink ? and what is the alternatives for joint sensor and joint actuator in matlab 2018a?srag zhranhttps://in.mathworks.com/matlabcentral/profile/authors/15285542-srag-zhrantag:in.mathworks.com,2005:Question/5424172020-06-04T21:29:00Z2020-06-05T20:45:55ZPlot function with time step Hello, even if this question was posed in a similar way, I couldn't apply it to my issue, also given the fact I'm very new.
However, I got a set of values (.txt format: A= 4063x1). Thus the y-values are provided, I'd name them y = A{:,1}; Unfortunaly x values are missing, it's just being said time step = 0.000999. That's what is bothering me: how am I generating my line of x-values? It'd be most kind if you'd solve that trivial thing for me. Thx in advance. Niklas Kurzhttps://in.mathworks.com/matlabcentral/profile/authors/18516014-niklas-kurztag:in.mathworks.com,2005:Question/2607172015-12-17T12:13:20Z2020-06-05T20:42:28Zlibmwservices.dll missing after installationHello,
I just created an account and launched the installation. I tried several times, but every time download is finished and I tried to pen Matlab, I get the error message: "libmwservices.dll missing. Try to reinstall the program to fix the problem". Reinstalling is not helping, waht can I do please?
thank you Very much
Best regards,
AlexisALEXIS LE MILLINhttps://in.mathworks.com/matlabcentral/profile/authors/7339268-alexis-le-millintag:in.mathworks.com,2005:Question/5431282020-06-05T20:41:35Z2020-06-05T20:41:35ZHow to asynchronously control distinct workers in a parallel pool separatelyI have created a parallel pool of 2 workes, and I would like to control them seperately. My aim is to do something similar to semaphore.
My first worker will create a tcpip server, handle the communication with the client. Normally, it would wait in a Busy state until a connection is established, but I will put it in a worker and do not wait until parfeval future is finished.
My second worker will handle some data capturing.
Meanwhile client will handle some data processing of previously captured data.
The main problem is about using parallel pool with tcpip object.
In some threads, it is adviced to use parallel.pool.Constant to use tcpip object inside parallel pool.
However when I use parallel.pool.Constant, it tries to create tcpip server in both workers and I get "Adress already in use: JVM Bind" error. If it could asynchronously command workers as I desire, I would create tcpip server in a single pool and use in only inside that worker. Is that possible?
spmd is also not okay for me, since it waits until all workers complete their tasks and works synchronously.
My code is basically like following:
p = parpool(2);
is_connection_lost = 1;
is_connection_established = 0;
data_ready = 0;
is_processed_data_sent = 1;
f2 = parfeval(p,@capture_data,1); % Captures data in prior
while(1)
% Worker 1:
% Creates tcpip server,
% waits until connection is established,
% sends data
if is_connection_lost
f1 = parfeval(p,@tcpip_server_create,1);
is_connection_lost = 0;
end
if strcmp(f1.State, 'finished') && ~is_connection_established
[~,t] = fetchNext(f1); % Problem here is that tcpip server object comes as "off"
is_connection_established = 1;
end
if is_connection_established && ~is_processed_data_sent
f1 = parfeval(p,@tcpip_send_data,1,data_processed);
is_processed_data_sent = 1;
end
% For now, it does not check whether client is alive or not. Will be added.
% Worker 2:
% Captures data. Works fine.
if strcmp(f2.State, 'finished')
[~,data] = fetchNext(f2);
f2 = parfeval(p,@capture_data,1); % Starts capturing new data meanwhile
data_ready = 1;
end
% Matlab Client:
% Processes data. Works fine.
if data_ready == 1
data_processed = process_data(data);
data_ready = 0;
is_processed_data_sent = 0;
end
end
function t = tcpip_server_create
t = tcpip('0.0.0.0',5000,'networkrole','server');
fopen(t);
function data = capture_data
data = zeros(100); % Assume we captured this one
function data_processed = process_data(data)
data_processed = 2 * data; % Assume we processed this oneUtku Yilmazhttps://in.mathworks.com/matlabcentral/profile/authors/6712235-utku-yilmaztag:in.mathworks.com,2005:Question/5430742020-06-05T19:35:16Z2020-06-05T20:39:40Zfor loop showing only last iteration and the graph shows dotted instead of linesclc
close all
clear
syms x y E
v=[x y];
J=jacobian([y,E*(1-x^2)*y-x], v);
p=[0 0];
j=subs(J,v,p);
a=-8:0.1:8;
for E=a
e = eig(j);
c=subs(e,E);
u=double(c);
plot(E,real(u),'.'); hold on
end
i'm new to matlab and i scripted the above code from various helps online, in order to find the bifurcation but i can't get a line plot where all the dots are combined and i have tried changing the '.' to '-' but still doesn't work.
Also i need every iteration of u on the workspace, currently it's just showing only the last iteration value
Thank you.akhil roushttps://in.mathworks.com/matlabcentral/profile/authors/16861002-akhil-roustag:in.mathworks.com,2005:Question/943812013-09-06T17:42:00Z2020-06-05T20:34:11ZWhy does the MATLAB installer fail with an error related to a lxe_win64 or .enc file?When installing MATLAB on my machine I get an error like the following:
The following error was detected while installing lxe_win64:
Missing Entry: lxe_win64_1368859906.enc
OR
"Missing Entry: lxe_common_1384906630.enc
Would you like to retry installing lxe_win64/lxe_common? If you press NO, the installer will exit without completing the installation. More information can be found at C:\Users\<user_name>\AppData\Local\Temp\mathworks_<user_name>.log
MathWorks Support Teamhttps://in.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:in.mathworks.com,2005:Question/5408962020-06-02T21:10:42Z2020-06-05T20:33:15ZApp inside app questionHello MATLAB community!
I am an undergraduate new to MATLAB, and I am trying to build an app inside MATLAB to collect/analyze data for a neuroscience research project.
Is it possible to build an app (or in my case, four apps) within a "mother" app? I tried creating one app but it was ridiculously slow to load an image. I hope linking different apps will make this process much quicker.
If this is possible, how do I go about connecting the apps? Thanks so much!Lucia Wagnerhttps://in.mathworks.com/matlabcentral/profile/authors/11832909-lucia-wagnertag:in.mathworks.com,2005:Question/5430082020-06-05T17:53:21Z2020-06-05T20:27:07Zsaving variables programmatically using list of variable namesHi all,
This should be simple but I think my frustration level is keeping me from seeing the path.
I simply want to save some variables on the workspace based on a list of those variable names.
a=1;b=2;c=3
varNames = {'a','b','c'};
save('myMatFile',varNames)
which yields the error 'Error using save. Must be a string scalar or character vector'. (what must be a string scalar? File name? vars? Yes I know, vars, but still TMW...)
so how about
save('myMatFile',cell2mat({'a,','b,','c'});
yielding the more useful error 'a,b,c' is not a valid variable name.
I see where this is going, I must have a properly formatted string array akin to eval inputs. But there really should be an easier way, like my original attempt.
Thanks for the support and letting me rant a bit.
-Chrischeckerhttps://in.mathworks.com/matlabcentral/profile/authors/4894445-checkertag:in.mathworks.com,2005:Question/5431132020-06-05T20:23:59Z2020-06-05T20:23:59ZRubber-Silicon Fatigue ModelHow can I model rubber-Silocon fatigue in MATLAB or Simulink. I am trying to determine if a rubber-Silocon bushing will withstand multiple shock and vibe cycles.
Tinsile strength, psi, minimum 400
Ultimate elongation, percent, minimum 275
Tear resistance, die B, lb/in, minimum 50
Share A hardness, minimum 25
Specific gravity 1.12
Thermal conductivity, maximum 5.5x10-4
Djnhttps://in.mathworks.com/matlabcentral/profile/authors/10263603-djntag:in.mathworks.com,2005:Question/5429452020-06-05T16:06:19Z2020-06-05T20:19:39ZHow to read line with multiple separate headers and tabs in between valuesSo I was wondering about the following:
I have a simulation export from LTSpice with the following structure:
time V(vin) V(vout) I(B1) I(D1) I(Rload) I(V1)
Step Information: D=200m (Run: 1/13)
0.000000000000000e+000 1.291820e+001 1.247644e+001 2.187000e+000 2.186138e+000 2.970581e+000 -7.852747e-001
7.902717741844912e-011 1.291820e+001 1.247649e+001 2.187000e+000 2.188567e+000 2.970593e+000 -7.836857e-001
8.444024477795836e-011 1.291820e+001 1.247649e+001 2.187000e+000 2.188719e+000 2.970593e+000 -7.835863e-001
9.165766792397068e-011 1.291820e+001 1.247650e+001 2.187000e+000 2.188895e+000 2.970594e+000 -7.834706e-001
.
.
Step Information: D=250m (Run: 2/13)
(More data, same structure)
I am unable to read all lines as a string and keep the formatting intact, most likely due to the tabs that separate the data values. Is there a way to replace tabs by spaces with the `textscan` function or a way to keep the formatting?
clear all;
fid = fopen('s11.txt','r');
S = textscan(fid, '%s', 'delimiter', '\n', 'whitespace', '', 'TreatAsEmpty', '');
S = S{1};
fclose(fid);
% Find subheaders
idx = find(contains(S,'Step'));
cycle_data = cell(length(idx),1) ;
for i = 1:length(idx)-1
cycle_data{i} = S(idx(i)+1:idx(i+1)-1);
end
cycle_data{end} = S(idx(end)+1:end) ;
Which yields a matrix with 13 entries (all cycles/data subheaders separated) but the problem I get is that the data values are concatenated. More concise:
In an entry I get lines like this:
0.000000000000000e+0001.291820e+0011.247644e+0012.187000e+0002.186138e+0002.970581e+000-7.852747e-001
Instead of what I want:
0.000000000000000e+000 1.291820e+001 1.247644e+001 2.187000e+000 2.186138e+000 2.970581e+000 -7.852747e-001
Thanks in advance!
Ps. An alternative solution is also completely fine for me.Jethttps://in.mathworks.com/matlabcentral/profile/authors/6930071-jettag:in.mathworks.com,2005:Question/5431102020-06-05T20:18:00Z2020-06-05T20:18:33Z How to measure distance between two objects in video in metersHi
How to measure distance between two objects in video in meters
For instance the width of video is 640 and height is 480
Best,Abdussalam Elhanashihttps://in.mathworks.com/matlabcentral/profile/authors/15843739-abdussalam-elhanashitag:in.mathworks.com,2005:Question/5430802020-06-05T19:47:36Z2020-06-05T20:17:39ZPlotting datetime from datasetI have a two-column data set that I would like to plot. The data I would like to plot on the x-axis is datetime in the format yyyy-MM-dd refer to attached picture). What to I need to do to be able to plot the dates? I have not been able to find how to change them all into the correct format altogether, is this possible?
Kassidy Rose Sharitshttps://in.mathworks.com/matlabcentral/profile/authors/17358278-kassidy-rose-sharitstag:in.mathworks.com,2005:Question/5431072020-06-05T20:14:53Z2020-06-05T20:14:53ZIs. there a limit to the number of VNT CAN Transmit and CAN Receive blocks that can be used in a modelI have created a Simulink model which performs communications with a number of CAN devices that are included in our system. The CAN blocks are configured to use a KVaser Leaf Ligtht USB CAN tranceiver. This model used to work with VNT communications to all of these devices, but as I have added communications for more CAN nodes into the model, it has stopped working. I get an error message:
Could not open CAN device to connect to the network.
If I comment out one CAN node, this message goes away and the simulation runs again.
Is there a limit to the total number of VNT CAN Transmit and VNT CAN Receive blocks that can be used in a model?
If there is a limit, does anyone know a way around the limit. This is becoming a problem for my development.Joel Katzhttps://in.mathworks.com/matlabcentral/profile/authors/11940313-joel-katztag:in.mathworks.com,2005:Question/5431042020-06-05T20:09:53Z2020-06-05T20:09:53ZSimulink Scope - How does restore view work?I'm using the Simulink scope block in MATLAB 2020a and am having difficulty with the view setting. I like to know how to save views so that I can later recall them using the restore view function. You get there by double clicking the scope block after simulation and right clicking in the plot area (2nd item in the drop down menu is the "Restore View" option).
I can't seem to find any good entries that explain how the restore view function works, how to save a view so you can restore it later or what view exactly "restore view" restores.
Ted Kornashttps://in.mathworks.com/matlabcentral/profile/authors/15832853-ted-kornastag:in.mathworks.com,2005:Question/5431012020-06-05T20:01:47Z2020-06-05T20:01:47ZOverlay Trail Tracing Projectile I have created a code to overlay two baseball videos to help analyze the path of the pitches. I would like to add a dotted trail to pitches that are being overlayed in the video, as the ball travels its projected path. How can I add this dotted trail on the video? Below is my current code to produce the overlay video of pitches.
clc
clear all
mov1 = VideoReader('ball.avi');
mov2 = VideoReader('strike_1.avi');
mov1frames = read(mov1);
mov2frames = read(mov2);
points1 = dlmread('ball.txt',' ');
fit1 = polyval(polyfit(points1(:,3),points1(:,1),3),points1(1,3):points1(end,3));
fit2 = polyval(polyfit(points1(:,3),points1(:,2),3),points1(1,3):points1(end,3));
[x,y] = meshgrid(1:size(mov1frames,2), 1:size(mov1frames,1));
radius = 7;
keyframe = 82; enddif = 1;
movoverlay = mov2frames;
for i = 1:size(mov1frames,4)-keyframe-enddif
j = i+keyframe;
point = [fit1(i),fit2(i)];
isinside = (x - point(1,1)).^2 + (y - point(1,2)).^2 <= radius^2;
isinside2 = repmat(isinside,1,1,3);
temp = mov1frames(:,:,:,j);
temp2 = mov2frames(:,:,:,j);
temp2(isinside2==1) = temp(isinside2==1);
movoverlay(:,:,:,j) = temp2;
end
v = VideoWriter('overlay','Uncompressed AVI');
open(v)
writeVideo(v,movoverlay)
close(v)Matt Garciahttps://in.mathworks.com/matlabcentral/profile/authors/18101334-matt-garciatag:in.mathworks.com,2005:Question/5430922020-06-05T19:52:53Z2020-06-05T20:00:19ZScatter plot of two matrix of same sizeI have two matrix of same size (293 X 293 matrix) and i want to plot the scatter plot of these data as one matrix on X axis and one matrix on Y axix. but the matlab showing the error.
>> y=readmatrix('chr8norm_Nmin_matrix.txt');
>> x=readmatrix('chr8_spatial_distance_0.5_matrix_test.txt');
>> scatter(x,y)
Error using scatter (line 78)
X and Y must be vectors of the same length.
please help me out to solve this problemAshish Kumar Choudharyhttps://in.mathworks.com/matlabcentral/profile/authors/18278670-ashish-kumar-choudharytag:in.mathworks.com,2005:Question/5430982020-06-05T19:58:52Z2020-06-05T19:59:58ZEstimating inputs from outputs in neural networksIf I have a neural networks of 8 inputs and 6 outputs. Is it possible after training to estimate inputs from outputs? Yaserhttps://in.mathworks.com/matlabcentral/profile/authors/1570688-yaser