Al momento, stai seguendo questa domanda
- Vedrai gli aggiornamenti nel tuofeed del contenuto seguito.
- Potresti ricevere delle e-mail a seconda delle tuepreferenze per le comunicazioni.
is Matlab code a lot faster than Excel formulas?
6 Commenti
Risposta accettata
26 Commenti
- it's worth it to code the spreadsheet - although this use case may not be typical, there will be others in the future, it's worth the investment
- it will likely increase iteration speed - it seems that the concept of coding a spreadsheet to improve speed is sound (with caveats)
- caveat: the code will need to be well-written - a 1:1 translation of the spreadsheet will probably not produce the desired result
- Most of my data is double precision, but COM imports it as a cell matrix. cell2mat() seems to work, but I know from my searching that there are other solutions, using (i.e. [C{:}], C++ MEX) which are faster or more elegant. How would you convert these cell matrices to double precision matrices?
- The size of my SORT, CLOSE and DATA matrices will vary depending on the size of the dataset. I found this method (which you had input on) for importing data sets of varying size. Is there another way to do this without using keystrokes?
- Yes, the .Value property is always returned as the VBA Variant type which is a cell array in MATLAB parlance. My recommendation would be to develop the code first using normal MATLAB functions and only worry about fine-tuning performance once you have a working algorithm and can profile it to find bottlenecks. So, I'd start with cell2mat and stick with it until it was proven to be a significant source of overhead. It's SO much easier to debug simple-to-read, "deadahead" code than to also have to fight through arcane manipulations and remember what was the purpose of such machinations. You might save a few msec here, but I'll be very surprised to learn it turns out to be a significant fraction of the overall run time. After all, this is only a one-time thing on startup, isn't it?
- Yes, there are ways, but not magic ones. You'll have to have some sort of breadcrumbs to lead through the forest; if your spreadsheet has header rows to identify where things are, then one ploy is to first read the header row(s) and locate columns by finding specific variable names columns. Failing that, it becomes more difficult and would have to have details of the spreadsheet content that could somehow be used as waypoints to have any further insight. I'll refloat the previous idea to move completely away from the huge single spreadsheet paradigm, however, and go back to the source of the original data from which the spreadsheet was/is created and read it from those sources. Then it should already be of the given size and content without having to break it back out again.
- your points about not making a 1:1 translation from Excel -> Matlab are fully understood. I think the confusion was my assumption that I would have to adapt the way a spreadsheet does things to the way they can be done in code, so I never planned a "literal 1:1" translation.
- although this was not mentioned before, there is existing code that provides data which the spreadsheet uses, and it is written in C++. I'm not an experienced C++ coder (or experienced in coding at all), but I did write the code and can work in that environment. From what you all have said, C++ is very likely faster than Matlab.
- I've been taking time to modify the spreadsheet in preparation for converting it to code. Much of what has accumulated over time has been removed, and much of what is helpful has been kept and even fine-tuned. That's what I'm working on mainly now.
- For the moment, I think the wisest course of action, if speed is most important, is to make the (deeper) plunge into C++. It's not what I wanted to do, because I have a Matlab license available to me and a wonderful community to help, but it seems wise.
Più risposte (1)
2 Commenti
Vedere anche
Categorie
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Si è verificato un errore
Impossibile completare l'azione a causa delle modifiche apportate alla pagina. Ricarica la pagina per vedere lo stato aggiornato.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia-Pacifico
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)