Community Profile

photo

per isakson


KTH

2,006 total contributions since 2010

Contact

per isakson's Badges

  • Revival Level 3
  • Ace
  • 36 Month Streak
  • Thankful Level 3
  • Knowledgeable Level 4
  • First Answer
  • Leader
  • Speed Demon
  • Promoter
  • Commenter
  • Solver

View details...

Contributions in
View by

Answered
serveral normrnd without a loop
What about this? >> cell2mat( arrayfun( @(m,l) normrnd( m, sig, [1,l] ), mu, len, 'uni',false ) ) ans = Columns 1 through ...

9 hours ago | 0

Answered
How can I run a matlab program N times using a different value of one of my variables
Assumptions: You have a script. Lets call it myScript. The first line of myScript is clear all Near the top of myScript the...

13 hours ago | 0

Answered
How to remove \n and empty line after combine all the lines into an array
Replace fgets by fgetl fgetl, Read line from file, removing newline characters In response to comment To remove the endi...

13 hours ago | 1

| accepted

Answered
Replace numbers into a vector starts at the center? Looking for general format
Run this %% vec = [ 0 0 0 0 0 ]; vec1 = [ 1 1 1 ]; new_vec = [ 0 1 1 1 0 ]; %% len = length( vec ); len...

1 day ago | 1

| accepted

Answered
index exceeds matrix dimensions
Your profile shows that you over the last few months have posed ten questions in this forum and not received a single answer. Ar...

2 days ago | 1

| accepted

Answered
Loop is running only for certain value in the whole range
I'm not a fan of backward engineering of faulty code. The formula of one of your comments is the formula of a moving average. Ma...

2 days ago | 0

Answered
Using Property Blocks : Set/get on properties within a single property block
The problem is obviously to implement 'block','Data'. Try this >> myc = myClass myc = myClass with properties: na...

3 days ago | 1

| accepted

Answered
Class with dynamic properties but no handle
"like a stupid thing to ask" No that's definately a good question that deserves an answer. "how do I go from a handle class t...

3 days ago | 1

| accepted

Answered
Determine The Input Time with tic,toc
I assume that hObject is a uicontrol object of style edit. Your current script reads the elapse time of getting the current st...

5 days ago | 1

| accepted

Answered
Import .mat files and arrange some data in a matrix
Set Pause on Errors and run again Next see: Debug a MATLAB Program and Examine Values While Debugging

5 days ago | 0

| accepted

Answered
How to inherite and intialize object values
"How do I inherit inputDef in a another class such that [...]" See Composition over inheritance and try %% in = inputDef()...

5 days ago | 0

Answered
Replace the elements of a matrix
One way z = permute( A, [2,1] ); B = z(:); or z = permute( A, [2,1] ); B = reshape( z, [],1 );

6 days ago | 0

| accepted

Answered
Error in fprintf function
"Invalid file identifier. Use fopen to generate a valid file identifier". The problem is most likely with this line fid = fopen...

8 days ago | 1

Answered
From cell to matrix
One way %% cac = { [5,6],[5,12],[6,12] ; [7,11],[],[] ; [18,19],[],[] }; % your sample data ise = cellfun( @isempty, cac ); ...

8 days ago | 0

Answered
Table values that is a scalar string
On my system Win10, R2018b, Excel 2016 all the methods to reference the last column works. (I downloaded AA.xlsx from another qu...

11 days ago | 0

Answered
Question with for loop 'Index in position 1 exceeds array bounds (must not exceed 9)'
Line 9 arcStraight(ii,jj)=distance('rh',lats(ii,jj), lons(ii,jj),lats(ii+1,jj),lons(ii+1,jj),referenceEllipsoid(7030)); conta...

11 days ago | 1

| accepted

Answered
How to read only the first term on the file.
Try this %% ffs = 'h:\m\cssm\force.dat'; % change to your folder fid = fopen( ffs, 'r' ); cac = textscan( fid, '%*f%s%*s%*s'...

15 days ago | 1

| accepted

Answered
How to change time interval in timeseries plot?
See resample - Resample timeseries time vector retime - Resample or aggregate data in timetable, and resolve duplicate or irre...

20 days ago | 1

| accepted

Answered
renaming certain part of a file
Try this %% xpr = '^[^.]+\.([^.]+)\.{2}\w+?(\w)\.\w+\.\d{4}\.(\d+)\.'; %% old_name = 'LM.BARI..BHZ.D.2018.246.000000.txt'; ...

20 days ago | 0

Answered
Stuck at a For Loop
Notes from my debugging session: added your assignments of input values to the top of the script commented out the input() sta...

20 days ago | 0

Answered
Count Unique Occurrences of Elements
I cannot make comments, thus I use an Answer To ensure that Stops, Buses and UniqueBuses are row vectors add the following li...

20 days ago | 1

Answered
Count Unique Occurrences of Elements
Try this %% Stops = [ "w", "w", "x", "x", "x", "y", "z" ]; % String Buses = [ "A", "B", "C", "A", "C", "D", "B" ]; % Stri...

20 days ago | 1

| accepted

Answered
Optimized code for loop, If-statement for large dataset
Try this %% ixcol = [ 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19 ]; n=0; for i = 1 : length(d_A) if all( isnan( d_A( i...

21 days ago | 0

| accepted

Answered
A problem about using %f
Try this %% K = randi( [1e9,9e9], 1,9 ); % sample data %% cac = arrayfun( @(x) num2str(x), K, 'uni',false ); %% str = stri...

22 days ago | 0

| accepted

Answered
Listing only a certain value in from text file
Try this %% chr = fileread('cssm.txt'); %% cac = regexp( chr, '[\d\.]+(?=[\t\r ]*$)', 'match', 'lineanchors' ); num = str2d...

23 days ago | 0

Answered
Handling large data sets
Idea : Version 7.3 MAT-files are HDF5-files. Matlab has functions to read HDF5-files, Importing HDF5 Files. The tricky pa...

23 days ago | 0

Answered
Something is nuts. Why would a working script stopped working???
The line before is in error (the brackets aren't balanced) FileToSave=[FileToGet(1:end-4) ['.jpg'] The Code Analyzer box p...

23 days ago | 0

| accepted

Answered
fprintf - a troubling question
See Export Binary Data with Low-Level I/O . You should use fwrite(), not fprintf()

24 days ago | 0

Answered
How do I "use structures for function arguments"?
Try this S.x1 = 17 ; S.x2 = 18 ; S.text1 = 'ABC'; S.cmap1 = magic(3); S.cmap2 = magic(3); S.cmap3 = magic(...

24 days ago | 0

| accepted

Answered
Access to data without reading all of it
"I am slightly confused about the comments about search algorithm. [...] Is find function in Matlab not very efficient?" I'm co...

24 days ago | 0

| accepted

Load more